@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css");

@import url("./00_base.css");
@import url("./10_header_search.css");
@import url("./20_layout_chart.css");
@import url("./30_right_panel.css");
@import url("./40_indicators.css");
@import url("./50_modals.css");
@import url("./90_responsive.css");

/* =========================================================
   BitgakView V5 chart layer
   - 전역 override 금지
   - 차트 캔버스/라벨/로딩 레이어만 담당
   ========================================================= */

.chart-wrap-v5,
.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
}

.tv-chart-v5,
.tv-chart {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  background: #ffffff;
}

.drawing-layer {
  position: absolute;
  inset: 0;
  z-index: 24;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.chart-wrap.drawing-mode .drawing-layer {
  pointer-events: all;
  cursor: crosshair;
}

.chart-indicator-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: block;
  pointer-events: none;
}

.bv-v5-main-label,
.bv-v5-pane-label {
  position: absolute;
  left: 10px;
  z-index: 28;
  min-width: 88px;
  height: 22px;
  padding: 0 10px 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #ffffff;
  font-size: 11px;
  font-weight: 1000;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(8px);
}

.bv-v5-main-label::before,
.bv-v5-pane-label::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 999px;
  background: var(--label-color, #2563eb);
  box-shadow: 0 0 10px var(--label-color, #2563eb);
}

.bv-v5-pane-label-rsi { --label-color: #db2777; }
.bv-v5-pane-label-macd { --label-color: #2563eb; }
.bv-v5-pane-label-volume { --label-color: #64748b; }

.chart-loading {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
  color: #0f172a;
  font-size: 13px;
  font-weight: 900;
}

.chart-loading.show {
  display: flex;
}

/* TradingView lightweight logo/link 숨김 */
.tv-chart a,
.tv-chart a[href*="tradingview"],
.tv-chart a[href*="tradingview.com"],
.tv-lightweight-charts a {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}


/* =========================================================
   Investment note modal
   ========================================================= */
.my-stock-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(2, 6, 23, 0.66);
  backdrop-filter: blur(10px);
}

.my-stock-modal.open,
.my-stock-modal.is-open {
  display: flex;
}

.my-stock-panel {
  width: min(780px, calc(100vw - 32px));
  max-height: min(820px, calc(100vh - 42px));
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(96, 165, 250, 0.24);
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 36%),
    linear-gradient(180deg, #0f172a, #07101d);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  color: #ffffff;
}

.my-stock-head {
  flex: 0 0 auto;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.my-stock-head h2 {
  margin: 0;
  color: #ffffff;
  font-size: 22px;
  font-weight: 1000;
  letter-spacing: -0.05em;
}

.my-stock-head p {
  margin: 6px 0 0;
  color: #9fb0c8;
  font-size: 13px;
  font-weight: 800;
}

.my-stock-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 16px 20px 0;
}

.my-stock-summary-card {
  min-width: 0;
  padding: 14px;
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.48);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

.my-stock-summary-card span {
  display: block;
  color: #8aa3c3;
  font-size: 11px;
  font-weight: 900;
}

.my-stock-summary-card strong {
  display: block;
  margin-top: 7px;
  color: #ffffff;
  font-size: 18px;
  font-weight: 1000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.my-stock-table-wrap {
  margin: 16px 20px 0;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  overflow: auto;
  max-height: 260px;
  background: rgba(2, 6, 23, 0.36);
}

.my-stock-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.my-stock-table th,
.my-stock-table td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.10);
  color: #dbeafe;
  font-size: 13px;
  font-weight: 850;
  text-align: right;
  white-space: nowrap;
}

.my-stock-table th:first-child,
.my-stock-table td:first-child {
  text-align: left;
}

.my-stock-table th {
  color: #8aa3c3;
  background: rgba(15, 23, 42, 0.48);
  font-size: 12px;
  font-weight: 1000;
}

.my-stock-table tr:last-child td {
  border-bottom: 0;
}

.my-stock-memo {
  display: grid;
  gap: 8px;
  margin: 16px 20px 0;
}

.my-stock-memo span {
  color: #9fb0c8;
  font-size: 12px;
  font-weight: 1000;
}

.my-stock-memo textarea {
  width: 100%;
  min-height: 94px;
  resize: vertical;
  border-radius: 16px;
  border: 1px solid rgba(96, 165, 250, 0.24);
  background: rgba(2, 6, 23, 0.56);
  color: #ffffff;
  padding: 12px;
  outline: none;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.55;
}

.my-stock-memo textarea:focus {
  border-color: rgba(56, 189, 248, 0.70);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.10);
}

.my-stock-actions {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 16px 20px 20px;
}

.my-stock-actions button {
  height: 40px;
  padding: 0 15px;
  border: 0;
  border-radius: 13px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 1000;
}

.my-stock-save {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
}

.my-stock-delete {
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca !important;
}


/* =========================================================
   Recover v2 safety layout
   - 20_layout_chart.css가 캐시되어도 최종 레이아웃을 보호
   ========================================================= */
.bitgak-chart-body .bv-layout,
.bitgak-chart-body .bv-layout-full {
  grid-template-columns: 520px minmax(430px, 1fr) 320px;
}

.bitgak-chart-body .bv-left-panel {
  width: auto;
  min-width: 0;
  padding: 14px 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.bitgak-chart-body .avg-calc-card {
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.bitgak-chart-body .avg-calc-row {
  grid-template-columns: 62px 88px 66px minmax(128px, 1fr) 58px;
}

.bitgak-chart-body .avg-calc-row output {
  text-align: left;
}

.bitgak-chart-body .avg-row-actions {
  width: 56px;
  min-width: 56px;
  display: inline-flex;
  justify-content: flex-end;
  gap: 4px;
}

.bitgak-chart-body .invest-chart-badge {
  right: 12px;
  bottom: 42px;
  left: auto;
  top: auto;
}

@media (max-width: 1700px) {
  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full {
    grid-template-columns: 500px minmax(420px, 1fr) 300px;
  }

  .bitgak-chart-body .avg-calc-row {
    grid-template-columns: 58px 84px 60px minmax(118px, 1fr) 54px;
  }
}

@media (max-width: 1450px) {
  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full {
    grid-template-columns: 480px minmax(0, 1fr);
  }

  .bitgak-chart-body .bv-symbol-panel {
    display: none;
  }
}

@media (max-width: 1120px) {
  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full {
    grid-template-columns: 1fr;
  }

  .bitgak-chart-body .bv-left-panel {
    display: none;
  }
}


/* =========================================================
   Compact calc + palette safety layout
   ========================================================= */
.bitgak-chart-body .bv-layout,
.bitgak-chart-body .bv-layout-full {
  grid-template-columns: 470px minmax(500px, 1fr) 320px;
}

.bitgak-chart-body .bv-left-panel {
  padding: 14px;
}

.bitgak-chart-body .avg-calc-card {
  padding: 16px 14px;
}

.bitgak-chart-body .avg-calc-row {
  grid-template-columns: 60px 84px 64px 104px 52px;
}

.bitgak-chart-body .avg-calc-row output {
  text-align: left;
}

.bitgak-chart-body .avg-row-actions {
  width: 52px;
  min-width: 52px;
}

@media (max-width: 1700px) {
  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full {
    grid-template-columns: 455px minmax(460px, 1fr) 300px;
  }

  .bitgak-chart-body .avg-calc-row {
    grid-template-columns: 58px 80px 60px 100px 50px;
  }
}

@media (max-width: 1450px) {
  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full {
    grid-template-columns: 450px minmax(0, 1fr);
  }
}


/* =========================================================
   Auto-save + compact amount + top-left note final safety
   ========================================================= */
.bitgak-chart-body .bv-layout,
.bitgak-chart-body .bv-layout-full {
  grid-template-columns: 450px minmax(520px, 1fr) 320px;
}

.bitgak-chart-body .avg-calc-row {
  grid-template-columns: 58px 102px 62px 76px 52px;
}

.bitgak-chart-body .avg-calc-row output {
  text-align: left;
}

.bitgak-chart-body .avg-calc-row .avg-price-input {
  max-width: 102px;
}

.bitgak-chart-body .avg-calc-row .avg-amount-output {
  max-width: 76px;
}

.bitgak-chart-body .avg-line-color-button {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 0 2px rgba(2, 6, 23, 0.60);
}

.bitgak-chart-body .avg-line-color-button:hover,
.bitgak-chart-body .avg-line-color-button.active {
  border-color: rgba(255, 255, 255, 0.32);
  box-shadow:
    inset 0 0 0 2px rgba(2, 6, 23, 0.58),
    0 0 0 3px rgba(255, 255, 255, 0.08);
}

.bitgak-chart-body .avg-color-dot:hover,
.bitgak-chart-body .avg-color-dot.active {
  outline: none;
}

.bitgak-chart-body .avg-color-dot.active {
  box-shadow:
    inset 0 0 0 3px rgba(2, 6, 23, 0.68),
    0 0 0 2px rgba(255, 255, 255, 0.58),
    0 10px 18px rgba(0, 0, 0, 0.24);
}

.bitgak-chart-body .invest-chart-badge {
  left: 12px;
  top: 12px;
  right: auto;
  bottom: auto;
}

.bitgak-chart-body .bv-v5-pane-label {
  height: 24px;
  min-width: 96px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.84);
}

@media (max-width: 1700px) {
  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full {
    grid-template-columns: 440px minmax(500px, 1fr) 300px;
  }

  .bitgak-chart-body .avg-calc-row {
    grid-template-columns: 56px 96px 58px 72px 50px;
  }
}

@media (max-width: 1450px) {
  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full {
    grid-template-columns: 430px minmax(0, 1fr);
  }
}


/* =========================================================
   Pane/calc/search fix final safety
   ========================================================= */
.bitgak-chart-body .avg-calc-row {
  grid-template-columns: 42px minmax(112px, 1fr) 72px 96px 52px;
}

.bitgak-chart-body .avg-line-style-panel {
  grid-template-columns: 46px 74px minmax(0, 1fr) 70px 72px;
}

.bitgak-chart-body .avg-calc-row .avg-price-input {
  max-width: none;
}

.bitgak-chart-body .avg-calc-row .avg-qty-input {
  max-width: 72px;
}

.bitgak-chart-body .avg-calc-row .avg-amount-output {
  max-width: 96px;
  text-align: left;
}

.bitgak-chart-body .avg-line-color-button {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 0 2px rgba(2, 6, 23, 0.60);
}

.bitgak-chart-body .avg-line-color-button:hover,
.bitgak-chart-body .avg-line-color-button.active {
  border-color: rgba(255, 255, 255, 0.32);
  box-shadow:
    inset 0 0 0 2px rgba(2, 6, 23, 0.58),
    0 0 0 3px rgba(255, 255, 255, 0.08);
}

.bitgak-chart-body .avg-color-dot:hover,
.bitgak-chart-body .avg-color-dot.active {
  outline: none;
}

.bitgak-chart-body .avg-color-dot.active {
  box-shadow:
    inset 0 0 0 3px rgba(2, 6, 23, 0.68),
    0 0 0 2px rgba(255, 255, 255, 0.58),
    0 10px 18px rgba(0, 0, 0, 0.24);
}

.bitgak-chart-body .bv-v5-pane-label {
  height: 24px;
  min-width: 76px;
  padding: 0 10px 0 8px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.86);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.22);
}

.bitgak-chart-body .invest-chart-badge {
  left: 12px;
  top: 12px;
  right: auto;
  bottom: auto;
}


/* =========================================================
   Final UI note / pane / search safety
   ========================================================= */
.bitgak-chart-body .avg-line-style-panel {
  grid-template-columns: 74px minmax(0, 1fr) 70px 72px;
}

.bitgak-chart-body .avg-line-style-panel > span {
  display: none;
}

.bitgak-chart-body .avg-line-color-button,
.bitgak-chart-body .avg-line-color-button:hover,
.bitgak-chart-body .avg-line-color-button.active {
  border: 0;
  box-shadow: none;
}

.bitgak-chart-body .avg-color-dot,
.bitgak-chart-body .avg-color-dot:hover,
.bitgak-chart-body .avg-color-dot.active {
  outline: none;
  box-shadow: none;
  transform: none;
}

.bitgak-chart-body .invest-chart-badge {
  background: var(--note-bg, rgba(15, 23, 42, 0.82));
  color: var(--note-text, #eaf2ff);
}

.bitgak-chart-body .invest-chart-badge b {
  color: var(--note-accent, #67e8f9);
}

.bitgak-chart-body .bv-search {
  width: min(430px, 34vw);
  min-width: 280px;
  height: 40px;
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.26);
  background: rgba(15, 23, 42, 0.96);
}

.bitgak-chart-body .bv-search input {
  flex: 1 1 auto;
  width: auto;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #eaf2ff;
  padding: 0 14px 0 18px;
  font-size: 14px;
  font-weight: 850;
}

.bitgak-chart-body .bv-search button {
  flex: 0 0 36px;
  width: 36px;
  height: 100%;
  border: 0;
  border-left: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 0 999px 999px 0;
  background: transparent;
  color: #a8c7f7;
}

.bitgak-chart-body .bv-v5-pane-label {
  min-width: 64px;
  height: 24px;
  z-index: 40;
}

.bitgak-chart-body .bv-header-actions button#copyCodeBtn {
  display: none;
}


/* =========================================================
   note-style-save-pane-v2
   ========================================================= */

/* 속성창: 글자 없이 매수/색상/선/두께가 일정한 간격으로 배치 */
.avg-line-style-panel,
.bitgak-chart-body .avg-line-style-panel {
  grid-template-columns: 86px 86px minmax(74px, 1fr) 72px;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
}

.avg-line-style-panel > span,
.bitgak-chart-body .avg-line-style-panel > span {
  display: none;
}

.avg-line-type-select,
.avg-line-style-panel select {
  height: 32px;
  border-radius: 11px;
}

.avg-line-color-wrap,
.bitgak-chart-body .avg-line-color-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  padding-left: 0;
}

.avg-line-color-label {
  color: #cbd5e1;
  font-size: 10px;
  font-weight: 900;
}

/* 색상 원은 테두리 없이 색상만 보이게 */
.avg-line-color-button,
.avg-line-color-button:hover,
.avg-line-color-button.active,
.bitgak-chart-body .avg-line-color-button,
.bitgak-chart-body .avg-line-color-button:hover,
.bitgak-chart-body .avg-line-color-button.active {
  width: 28px;
  height: 28px;
  border: 0;
  outline: 0;
  border-radius: 999px;
  background: var(--line-color, #60a5fa);
  box-shadow: none;
}

.avg-color-dot,
.avg-color-dot:hover,
.avg-color-dot.active,
.bitgak-chart-body .avg-color-dot,
.bitgak-chart-body .avg-color-dot:hover,
.bitgak-chart-body .avg-color-dot.active {
  border: 0;
  outline: 0;
  box-shadow: none;
  transform: none;
}

.avg-color-dot.active,
.bitgak-chart-body .avg-color-dot.active {
  box-shadow:
    inset 0 0 0 3px rgba(2, 6, 23, 0.62),
    0 0 0 2px rgba(255, 255, 255, 0.50);
}

/* 투자노트 모달: 색상 커스터마이징 */
.my-stock-style-box {
  margin: 16px 20px 0;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(2, 6, 23, 0.36);
  display: grid;
  gap: 12px;
}

.my-stock-style-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.my-stock-style-row > span {
  color: #9fb0c8;
  font-size: 12px;
  font-weight: 1000;
}

.note-color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.note-color-palette button {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: var(--dot-color);
  box-shadow: none;
}

.note-color-palette button.active {
  box-shadow:
    inset 0 0 0 3px rgba(2, 6, 23, 0.58),
    0 0 0 2px rgba(255,255,255,0.48);
}

.invest-chart-badge {
  background: var(--note-bg, rgba(15, 23, 42, 0.82));
  color: var(--note-text, #eaf2ff);
  border-color: color-mix(in srgb, var(--note-accent, #67e8f9) 40%, transparent);
}

.invest-chart-badge strong,
.invest-chart-badge em,
.invest-chart-badge small,
.invest-chart-badge span {
  color: var(--note-text, #eaf2ff);
}

.invest-chart-badge b {
  color: var(--note-accent, #67e8f9);
}

/* 보조지표 라벨은 이름만 깨지지 않게 */
.bv-v5-pane-label,
.bitgak-chart-body .bv-v5-pane-label {
  min-width: 82px;
  height: 26px;
  padding: 0 11px 0 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  overflow: visible;
  z-index: 42;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.24);
}

.bv-v5-pane-label::before {
  flex: 0 0 auto;
}

.bitgak-chart-body .avg-line-color-wrap input[type='color'] { display: none; }


/* =========================================================
   Note preview dropdown v4
   ========================================================= */
.my-stock-style-box.note-style-editor,
.bitgak-chart-body .my-stock-style-box.note-style-editor {
  margin: 16px 20px 0;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(2, 6, 23, 0.36);
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 255px;
  gap: 14px;
  align-items: stretch;
}

.note-style-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}

.note-color-control {
  position: relative;
  min-width: 0;
  height: 54px;
  padding: 0 12px;
  border-radius: 15px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(15, 23, 42, 0.54);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.note-color-control > span {
  color: #9fb0c8;
  font-size: 12px;
  font-weight: 1000;
  white-space: nowrap;
}

.note-color-button {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 0;
  outline: 0;
  border-radius: 999px;
  background: var(--note-dot-color, #67e8f9);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10), 0 8px 16px rgba(0,0,0,0.22);
}

.note-color-button:hover,
.note-color-button.active {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 2px rgba(2, 6, 23, 0.45), 0 0 0 2px rgba(255,255,255,0.28), 0 10px 18px rgba(0,0,0,0.26);
}

.note-color-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 10030;
  width: 226px;
  padding: 12px;
  border-radius: 17px;
  border: 1px solid rgba(96, 165, 250, 0.24);
  background: rgba(8, 17, 31, 0.985);
  box-shadow: 0 20px 54px rgba(0,0,0,0.42);
  backdrop-filter: blur(14px);
  display: none;
  grid-template-columns: repeat(5, 32px);
  gap: 9px;
}

.note-color-popover.open {
  display: grid;
}

.note-color-popover button {
  width: 32px;
  height: 32px;
  border: 0;
  outline: 0;
  border-radius: 999px;
  background: var(--dot-color);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
}

.note-color-popover button.active {
  box-shadow: inset 0 0 0 3px rgba(2, 6, 23, 0.62), 0 0 0 2px rgba(255,255,255,0.48);
}

.note-style-preview-card {
  min-height: 118px;
  padding: 13px 14px;
  border-radius: 16px;
  background: var(--note-bg, rgba(15, 23, 42, 0.82));
  color: var(--note-text, #eaf2ff);
  border: 1px solid color-mix(in srgb, var(--note-accent, #67e8f9) 40%, transparent);
  box-shadow: 0 18px 36px rgba(0,0,0,0.22);
}

.note-style-preview-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--note-text, #eaf2ff);
  font-size: 13px;
  font-weight: 1000;
}

.note-style-preview-card span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  line-height: 1.55;
  color: var(--note-text, #eaf2ff);
  font-size: 11px;
  font-weight: 900;
}

.note-style-preview-card em {
  color: var(--note-text, #eaf2ff);
  font-style: normal;
  opacity: 0.86;
}

.note-style-preview-card b {
  color: var(--note-accent, #67e8f9);
  font-weight: 1000;
}

.note-style-preview-trades {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.note-style-preview-trades small {
  display: block;
  color: var(--note-text, #eaf2ff);
  opacity: 0.86;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-color-palette {
  display: none;
}

.my-stock-save.saved {
  background: linear-gradient(135deg, #10b981, #06b6d4);
}

.invest-chart-badge,
.note-style-preview-card {
  background: var(--note-bg, rgba(15, 23, 42, 0.82));
  color: var(--note-text, #eaf2ff);
}

.invest-chart-badge strong,
.invest-chart-badge em,
.invest-chart-badge small,
.invest-chart-badge span {
  color: var(--note-text, #eaf2ff);
}

.invest-chart-badge b {
  color: var(--note-accent, #67e8f9);
}


/* =========================================================
   Note color rows v5
   - 색상 선택을 3행 구조로 배치
   - 팔레트는 absolute가 아니라 아래로 펼쳐져 겹치지 않음
   ========================================================= */
.my-stock-style-box.note-style-editor.note-style-rows,
.bitgak-chart-body .my-stock-style-box.note-style-editor.note-style-rows {
  margin: 16px 20px 0;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(2, 6, 23, 0.36);
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 255px;
  gap: 14px;
  align-items: start;
}

.note-style-rows .note-style-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-content: start;
}

.note-style-rows .note-color-control {
  position: relative;
  min-width: 0;
  min-height: 54px;
  height: auto;
  padding: 0;
  border-radius: 15px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(15, 23, 42, 0.54);
  display: grid;
  grid-template-columns: 1fr;
  overflow: visible;
}

.note-color-control-head {
  height: 54px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.note-color-control-head > span {
  color: #9fb0c8;
  font-size: 12px;
  font-weight: 1000;
  white-space: nowrap;
}

.note-style-rows .note-color-button {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 0;
  outline: 0;
  border-radius: 999px;
  background: var(--note-dot-color, #67e8f9);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.10),
    0 8px 16px rgba(0,0,0,0.22);
}

.note-style-rows .note-color-button:hover,
.note-style-rows .note-color-button.active {
  transform: translateY(-1px);
  box-shadow:
    inset 0 0 0 2px rgba(2, 6, 23, 0.45),
    0 0 0 2px rgba(255,255,255,0.28),
    0 10px 18px rgba(0,0,0,0.26);
}

/* 기존 absolute popover를 아래 펼침형으로 완전히 전환 */
.note-style-rows .note-color-popover,
.bitgak-chart-body .note-style-rows .note-color-popover {
  position: static;
  width: auto;
  max-width: none;
  margin: 0 12px 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(96, 165, 250, 0.18);
  background: rgba(8, 17, 31, 0.96);
  box-shadow: none;
  backdrop-filter: none;
  display: none;
  grid-template-columns: repeat(8, 30px);
  gap: 9px;
  z-index: auto;
}

.note-style-rows .note-color-popover.open,
.bitgak-chart-body .note-style-rows .note-color-popover.open {
  display: grid;
}

.note-style-rows .note-color-popover button {
  width: 30px;
  height: 30px;
  border: 0;
  outline: 0;
  border-radius: 999px;
  background: var(--dot-color);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
}

.note-style-rows .note-color-popover button:hover {
  transform: translateY(-1px);
}

.note-style-rows .note-color-popover button.active {
  box-shadow:
    inset 0 0 0 3px rgba(2, 6, 23, 0.62),
    0 0 0 2px rgba(255,255,255,0.52);
}

.note-style-rows .note-style-preview-card {
  position: sticky;
  top: 12px;
  min-height: 124px;
  padding: 13px 14px;
  border-radius: 16px;
  background: var(--note-bg, rgba(15, 23, 42, 0.82));
  color: var(--note-text, #eaf2ff);
  border: 1px solid color-mix(in srgb, var(--note-accent, #67e8f9) 40%, transparent);
  box-shadow: 0 18px 36px rgba(0,0,0,0.22);
}

.note-style-rows .note-style-preview-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--note-text, #eaf2ff);
  font-size: 13px;
  font-weight: 1000;
}

.note-style-rows .note-style-preview-card span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  line-height: 1.55;
  color: var(--note-text, #eaf2ff);
  font-size: 11px;
  font-weight: 900;
}

.note-style-rows .note-style-preview-card em {
  color: var(--note-text, #eaf2ff);
  font-style: normal;
  opacity: 0.86;
}

.note-style-rows .note-style-preview-card b {
  color: var(--note-accent, #67e8f9);
  font-weight: 1000;
}

.note-style-rows .note-style-preview-trades {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.note-style-rows .note-style-preview-trades small {
  display: block;
  color: var(--note-text, #eaf2ff);
  opacity: 0.86;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 이전 항상 표시 팔레트는 숨김 */
.note-color-palette {
  display: none;
}

.my-stock-save.saved {
  background: linear-gradient(135deg, #10b981, #06b6d4);
}

.invest-chart-badge,
.note-style-preview-card {
  background: var(--note-bg, rgba(15, 23, 42, 0.82));
  color: var(--note-text, #eaf2ff);
}

.invest-chart-badge strong,
.invest-chart-badge em,
.invest-chart-badge small,
.invest-chart-badge span {
  color: var(--note-text, #eaf2ff);
}

.invest-chart-badge b {
  color: var(--note-accent, #67e8f9);
}


/* =========================================================
   Floating palette + avgline v6
   - 색상 팔레트는 화면을 밀지 않는 고정 팝업
   - 내 평단 라인 색상/선/두께 설정 추가
   ========================================================= */
.my-stock-style-box.note-style-editor.note-style-floating,
.bitgak-chart-body .my-stock-style-box.note-style-editor.note-style-floating {
  margin: 16px 20px 0;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(2, 6, 23, 0.36);
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 255px;
  gap: 14px;
  align-items: start;
  overflow: visible;
}

.note-style-floating .note-style-main {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.note-style-floating .note-style-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.note-style-floating .note-color-control {
  position: relative;
  min-width: 0;
  height: 54px;
  padding: 0 13px;
  border-radius: 15px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(15, 23, 42, 0.54);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  overflow: visible;
}

.note-style-floating .note-color-control > span {
  color: #9fb0c8;
  font-size: 12px;
  font-weight: 1000;
  white-space: nowrap;
}

.note-style-floating .note-color-button,
.avgline-color-button {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 0;
  outline: 0;
  border-radius: 999px;
  background: var(--note-dot-color, var(--avgline-dot-color, #67e8f9));
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.10),
    0 8px 16px rgba(0,0,0,0.22);
}

.note-style-floating .note-color-button:hover,
.note-style-floating .note-color-button.active,
.avgline-color-button:hover,
.avgline-color-button.active {
  transform: translateY(-1px);
  box-shadow:
    inset 0 0 0 2px rgba(2, 6, 23, 0.45),
    0 0 0 2px rgba(255,255,255,0.28),
    0 10px 18px rgba(0,0,0,0.26);
}

/* 화면을 밀지 않는 고정 팔레트 */
.note-style-floating .note-color-popover,
.bitgak-chart-body .note-style-floating .note-color-popover {
  position: fixed;
  z-index: 10080;
  width: 292px;
  max-width: calc(100vw - 24px);
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(96, 165, 250, 0.24);
  background: rgba(8, 17, 31, 0.985);
  box-shadow: 0 26px 72px rgba(0,0,0,0.48);
  backdrop-filter: blur(14px);
  display: none;
  grid-template-columns: repeat(6, 34px);
  gap: 10px;
}

.note-style-floating .note-color-popover.open,
.bitgak-chart-body .note-style-floating .note-color-popover.open {
  display: grid;
}

.note-style-floating .note-color-popover button {
  width: 34px;
  height: 34px;
  border: 0;
  outline: 0;
  border-radius: 999px;
  background: var(--dot-color);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
}

.note-style-floating .note-color-popover button:hover {
  transform: translateY(-1px);
}

.note-style-floating .note-color-popover button.active {
  box-shadow:
    inset 0 0 0 3px rgba(2, 6, 23, 0.62),
    0 0 0 2px rgba(255,255,255,0.52);
}

/* 내 평단 라인 설정 */
.avgline-style-control {
  padding: 13px;
  border-radius: 15px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(15, 23, 42, 0.54);
}

.avgline-style-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.avgline-style-head strong {
  color: #ffffff;
  font-size: 13px;
  font-weight: 1000;
}

.avgline-style-head span {
  color: #8aa3c3;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.avgline-style-fields {
  display: grid;
  grid-template-columns: 86px 1fr 1fr;
  gap: 9px;
}

.avgline-style-fields label,
.avgline-color-control {
  position: relative;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(2, 6, 23, 0.40);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.avgline-style-fields label > span,
.avgline-color-control > span {
  color: #9fb0c8;
  font-size: 11px;
  font-weight: 1000;
  white-space: nowrap;
}

.avgline-style-fields select {
  min-width: 0;
  height: 30px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
}

.note-style-floating .note-style-preview-card {
  position: sticky;
  top: 12px;
  min-height: 124px;
  padding: 13px 14px;
  border-radius: 16px;
  background: var(--note-bg, rgba(15, 23, 42, 0.82));
  color: var(--note-text, #eaf2ff);
  border: 1px solid color-mix(in srgb, var(--note-accent, #67e8f9) 40%, transparent);
  box-shadow: 0 18px 36px rgba(0,0,0,0.22);
}

.note-style-floating .note-style-preview-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--note-text, #eaf2ff);
  font-size: 13px;
  font-weight: 1000;
}

.note-style-floating .note-style-preview-card span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  line-height: 1.55;
  color: var(--note-text, #eaf2ff);
  font-size: 11px;
  font-weight: 900;
}

.note-style-floating .note-style-preview-card em {
  color: var(--note-text, #eaf2ff);
  font-style: normal;
  opacity: 0.86;
}

.note-style-floating .note-style-preview-card b {
  color: var(--note-accent, #67e8f9);
  font-weight: 1000;
}

.note-style-floating .note-style-preview-trades {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.note-style-floating .note-style-preview-trades small {
  display: block;
  color: var(--note-text, #eaf2ff);
  opacity: 0.86;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-color-palette {
  display: none;
}

.my-stock-save.saved {
  background: linear-gradient(135deg, #10b981, #06b6d4);
}

.invest-chart-badge,
.note-style-preview-card {
  background: var(--note-bg, rgba(15, 23, 42, 0.82));
  color: var(--note-text, #eaf2ff);
}

.invest-chart-badge strong,
.invest-chart-badge em,
.invest-chart-badge small,
.invest-chart-badge span {
  color: var(--note-text, #eaf2ff);
}

.invest-chart-badge b {
  color: var(--note-accent, #67e8f9);
}


/* =========================================================
   Note inline colors + avgline below + dark dropdown v7
   - 노트 배경/내용 색상/글자 색상은 1줄
   - 내 평단 라인은 그 아래 줄
   - select 드롭다운은 어두운 UI로 가독성 개선
   ========================================================= */

/* 모달 색상/평단 설정 영역 */
.my-stock-style-box.note-style-editor.note-style-floating,
.bitgak-chart-body .my-stock-style-box.note-style-editor.note-style-floating {
  grid-template-columns: minmax(430px, 1fr) 255px;
  align-items: start;
  overflow: visible;
}

.note-style-floating .note-style-main {
  display: grid;
  grid-template-rows: auto auto;
  gap: 10px;
  min-width: 0;
}

/* 노트 배경 / 내용 색상 / 글자 색상: 한 줄 3칸 */
.note-style-floating .note-style-controls,
.bitgak-chart-body .note-style-floating .note-style-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.note-style-floating .note-color-control,
.bitgak-chart-body .note-style-floating .note-color-control {
  height: 54px;
  min-width: 0;
  padding: 0 12px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.note-style-floating .note-color-control > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 내 평단 라인: 색상 3개 아래에 한 줄 */
.avgline-style-control,
.bitgak-chart-body .avgline-style-control {
  margin-top: 0;
  padding: 13px;
}

.avgline-style-fields,
.bitgak-chart-body .avgline-style-fields {
  grid-template-columns: 104px minmax(120px, 1fr) minmax(92px, 0.7fr);
  gap: 9px;
}

/* 드롭다운 가독성 개선 */
.avgline-style-fields select,
.avg-line-style-panel select,
.avg-calc-row select,
.bitgak-chart-body .avgline-style-fields select,
.bitgak-chart-body .avg-line-style-panel select,
.bitgak-chart-body .avg-calc-row select {
  color-scheme: dark;
  background: #071224;
  color: #f8fafc;
  border: 1px solid rgba(96, 165, 250, 0.24);
  border-radius: 11px;
  font-weight: 950;
  outline: none;
}

.avgline-style-fields select:hover,
.avg-line-style-panel select:hover,
.avg-calc-row select:hover {
  border-color: rgba(96, 165, 250, 0.45);
  background: #0b1730;
}

.avgline-style-fields select:focus,
.avg-line-style-panel select:focus,
.avg-calc-row select:focus {
  border-color: rgba(56, 189, 248, 0.70);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.avgline-style-fields select option,
.avg-line-style-panel select option,
.avg-calc-row select option {
  background: #0f172a;
  color: #f8fafc;
  font-weight: 900;
}

.avgline-style-fields select option:checked,
.avg-line-style-panel select option:checked,
.avg-calc-row select option:checked {
  background: #1d4ed8;
  color: #ffffff;
}

/* 기존 v6/v5에서 남아있는 1열 스타일보다 우선 적용 */
.note-style-floating .note-style-controls > .note-color-control {
  width: auto;
}

/* 색상 팔레트는 레이아웃을 밀지 않는 floating 유지 */
.note-style-floating .note-color-popover,
.bitgak-chart-body .note-style-floating .note-color-popover {
  position: fixed;
  z-index: 10080;
}

@media (max-width: 920px) {
  .my-stock-style-box.note-style-editor.note-style-floating,
  .bitgak-chart-body .my-stock-style-box.note-style-editor.note-style-floating {
    grid-template-columns: 1fr;
  }

  .note-style-floating .note-style-preview-card {
    position: static;
  }
}

@media (max-width: 760px) {
  .note-style-floating .note-style-controls,
  .bitgak-chart-body .note-style-floating .note-style-controls {
    grid-template-columns: 1fr;
  }

  .avgline-style-fields,
  .bitgak-chart-body .avgline-style-fields {
    grid-template-columns: 1fr;
  }
}


/* =========================================================
   TradingView style indicator panes v8
   ========================================================= */
.bv-v5-pane-label,
.bitgak-chart-body .bv-v5-pane-label {
  min-width: 72px;
  height: 25px;
  padding: 0 11px 0 9px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: #ffffff;
  font-size: 11px;
  font-weight: 1000;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.24);
  z-index: 42;
  pointer-events: none;
}

.bv-v5-pane-label::before {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--label-color, #60a5fa);
  box-shadow: 0 0 8px color-mix(in srgb, var(--label-color, #60a5fa) 70%, transparent);
}

/* =========================================================
   Portfolio drawer + on-demand average calculator
   ========================================================= */
.bitgak-chart-body .bv-header {
  gap: 12px;
}

.bitgak-chart-body .bv-drawer-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.bitgak-chart-body .bv-drawer-action-btn {
  height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(96, 165, 250, 0.32);
  border-radius: 13px;
  background: rgba(15, 23, 42, 0.72);
  color: #dbeafe;
  font-size: 13px;
  font-weight: 1000;
  letter-spacing: -0.04em;
  cursor: pointer;
  transition: .18s ease;
}

.bitgak-chart-body .bv-drawer-action-btn:hover,
.bitgak-chart-body .bv-drawer-action-btn.active {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  border-color: rgba(147, 197, 253, 0.7);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.24);
}

.bitgak-chart-body .bv-layout,
.bitgak-chart-body .bv-layout-full {
  grid-template-columns: minmax(620px, 1fr) 320px !important;
  transition: grid-template-columns .24s ease;
}

.bitgak-chart-body .bv-layout.bv-drawer-open,
.bitgak-chart-body .bv-layout-full.bv-drawer-open {
  grid-template-columns: 450px minmax(520px, 1fr) 320px !important;
}

.bitgak-chart-body .bv-left-panel.bv-tool-drawer {
  display: flex !important;
  min-width: 0 !important;
  width: auto !important;
  padding: 0 !important;
  overflow: hidden !important;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-18px);
  transition: opacity .22s ease, transform .22s ease;
}

.bitgak-chart-body .bv-layout.bv-drawer-open .bv-left-panel.bv-tool-drawer,
.bitgak-chart-body .bv-layout-full.bv-drawer-open .bv-left-panel.bv-tool-drawer {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.bitgak-chart-body .bv-tool-drawer {
  border-radius: 20px;
  border: 1px solid rgba(96, 165, 250, 0.24);
  background:
    radial-gradient(circle at 20% 0%, rgba(59, 130, 246, 0.16), transparent 34%),
    linear-gradient(180deg, #0f1b31, #06101f);
  box-shadow: 0 22px 54px rgba(2, 6, 23, .42);
  color: #ffffff;
}

.bitgak-chart-body .bv-tool-drawer-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.bitgak-chart-body .bv-tool-drawer-head strong {
  display: block;
  color: #ffffff;
  font-size: 18px;
  font-weight: 1000;
  letter-spacing: -0.05em;
}

.bitgak-chart-body .bv-tool-drawer-head span {
  display: block;
  margin-top: 4px;
  color: #9fb4d1;
  font-size: 12px;
  font-weight: 800;
}

.bitgak-chart-body .bv-tool-drawer-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.14);
  color: #dbeafe;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
}

.bitgak-chart-body .bv-tool-drawer-tabs {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.bitgak-chart-body .bv-tool-tab {
  height: 36px;
  border: 1px solid rgba(96, 165, 250, 0.22);
  border-radius: 13px;
  background: rgba(2, 6, 23, 0.34);
  color: #9fc5ff;
  font-size: 13px;
  font-weight: 1000;
  cursor: pointer;
}

.bitgak-chart-body .bv-tool-tab.active {
  background: rgba(37, 99, 235, 0.94);
  color: #ffffff;
  border-color: rgba(147, 197, 253, 0.64);
}

.bitgak-chart-body .bv-drawer-view {
  display: none;
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.bitgak-chart-body .bv-drawer-view.active {
  display: block;
}

.bitgak-chart-body .bv-drawer-view .avg-calc-card {
  margin: 0;
}

.bitgak-chart-body .avg-portfolio-save-box {
  margin-top: 10px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(96, 165, 250, 0.20);
  background: rgba(2, 6, 23, 0.28);
}

.bitgak-chart-body .avg-save-portfolio-btn {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #14b8a6);
  color: #ffffff;
  font-size: 14px;
  font-weight: 1000;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(20, 184, 166, 0.20);
}

.bitgak-chart-body .avg-portfolio-message {
  margin: 9px 0 0;
  color: #9fb4d1;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.bitgak-chart-body .avg-portfolio-message.ok { color: #67e8f9; }
.bitgak-chart-body .avg-portfolio-message.warn { color: #fde68a; }
.bitgak-chart-body .avg-portfolio-message.error { color: #fda4af; }

.bitgak-chart-body .portfolio-panel {
  color: #ffffff;
}

.bitgak-chart-body .portfolio-card {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(96, 165, 250, 0.20);
  background: rgba(2, 6, 23, 0.34);
  margin-bottom: 12px;
}

.bitgak-chart-body .portfolio-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.bitgak-chart-body .portfolio-section-head strong {
  display: block;
  color: #ffffff;
  font-size: 15px;
  font-weight: 1000;
  letter-spacing: -0.04em;
}

.bitgak-chart-body .portfolio-section-head span {
  display: block;
  margin-top: 4px;
  color: #8aa3c7;
  font-size: 12px;
  font-weight: 800;
}

.bitgak-chart-body .portfolio-capital-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 8px;
}

.bitgak-chart-body .portfolio-capital-row input {
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border-radius: 13px;
  border: 1px solid rgba(96, 165, 250, 0.28);
  background: rgba(2, 6, 23, 0.56);
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
  outline: none;
}

.bitgak-chart-body .portfolio-capital-row button,
.bitgak-chart-body .portfolio-fix-actions button,
.bitgak-chart-body .portfolio-view-tab {
  height: 42px;
  border: 1px solid rgba(96, 165, 250, 0.28);
  border-radius: 13px;
  background: rgba(37, 99, 235, 0.18);
  color: #dbeafe;
  font-size: 13px;
  font-weight: 1000;
  cursor: pointer;
}

.bitgak-chart-body .portfolio-capital-row button {
  background: #2563eb;
  color: #ffffff;
}

.bitgak-chart-body .portfolio-alert {
  margin-top: 10px;
  padding: 10px 11px;
  border-radius: 13px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(248, 113, 113, 0.26);
  color: #fecaca;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
}

.bitgak-chart-body .portfolio-fix-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.bitgak-chart-body .portfolio-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.bitgak-chart-body .portfolio-summary-card {
  min-width: 0;
  padding: 14px;
  border-radius: 17px;
  border: 1px solid rgba(96, 165, 250, 0.18);
  background: rgba(15, 23, 42, 0.50);
}

.bitgak-chart-body .portfolio-summary-card span {
  display: block;
  color: #8aa3c7;
  font-size: 11px;
  font-weight: 900;
}

.bitgak-chart-body .portfolio-summary-card strong {
  display: block;
  margin-top: 7px;
  color: #ffffff;
  font-size: 17px;
  font-weight: 1000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bitgak-chart-body .portfolio-summary-card strong.positive { color: #22d3ee; }
.bitgak-chart-body .portfolio-summary-card strong.negative { color: #fb7185; }

.bitgak-chart-body .portfolio-view-tabs {
  display: inline-flex;
  gap: 6px;
  flex: 0 0 auto;
}

.bitgak-chart-body .portfolio-view-tab {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.bitgak-chart-body .portfolio-view-tab.active {
  background: #2563eb;
  color: #ffffff;
}

.bitgak-chart-body .portfolio-donut-wrap {
  display: grid;
  grid-template-columns: 142px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.bitgak-chart-body .portfolio-donut {
  width: 142px;
  height: 142px;
  border-radius: 50%;
  position: relative;
  background: conic-gradient(#334155 0deg 360deg);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10), 0 14px 26px rgba(2,6,23,0.34);
}

.bitgak-chart-body .portfolio-donut::after {
  content: "";
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: #0b1424;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
}

.bitgak-chart-body .portfolio-donut span {
  position: absolute;
  inset: 38px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #ffffff;
  font-size: 13px;
  font-weight: 1000;
  line-height: 1.15;
}

.bitgak-chart-body .portfolio-donut small {
  margin-top: 4px;
  color: #8aa3c7;
  font-size: 10px;
  font-weight: 900;
}

.bitgak-chart-body .portfolio-legend {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.bitgak-chart-body .portfolio-legend-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: #dbeafe;
  font-size: 12px;
  font-weight: 900;
}

.bitgak-chart-body .portfolio-legend-row i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--legend-color);
}

.bitgak-chart-body .portfolio-legend-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bitgak-chart-body .portfolio-legend-row b {
  color: #ffffff;
}

.bitgak-chart-body .portfolio-holding-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.bitgak-chart-body .portfolio-holding-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 15px;
  border: 1px solid rgba(96, 165, 250, 0.16);
  background: rgba(15, 23, 42, 0.42);
  text-decoration: none;
}

.bitgak-chart-body .portfolio-holding-main strong {
  display: block;
  color: #ffffff;
  font-size: 13px;
  font-weight: 1000;
}

.bitgak-chart-body .portfolio-holding-main span {
  display: block;
  margin-top: 4px;
  color: #8aa3c7;
  font-size: 12px;
  font-weight: 850;
}

.bitgak-chart-body .portfolio-holding-values {
  text-align: right;
}

.bitgak-chart-body .portfolio-holding-values b {
  display: block;
  color: #ffffff;
  font-size: 13px;
  font-weight: 1000;
}

.bitgak-chart-body .portfolio-holding-values em {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-style: normal;
  font-weight: 1000;
}

.bitgak-chart-body .portfolio-holding-values em.positive { color: #22d3ee; }
.bitgak-chart-body .portfolio-holding-values em.negative { color: #fb7185; }

.bitgak-chart-body .portfolio-empty {
  padding: 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.44);
  color: #8aa3c7;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.45;
}

@media (max-width: 1450px) {
  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open {
    grid-template-columns: 430px minmax(0, 1fr) !important;
  }

  .bitgak-chart-body .bv-symbol-panel {
    display: none !important;
  }
}

@media (max-width: 1120px) {
  .bitgak-chart-body .bv-layout.bv-drawer-open,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open,
  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full {
    grid-template-columns: 1fr !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer {
    position: fixed;
    left: 10px;
    top: 86px;
    bottom: 12px;
    width: min(430px, calc(100vw - 20px)) !important;
    z-index: 9000;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer:not(.open) {
    display: none !important;
  }

  .bitgak-chart-body .bv-drawer-actions {
    width: 100%;
    order: 4;
  }

  .bitgak-chart-body .bv-drawer-action-btn {
    flex: 1 1 0;
  }
}



/* =========================================================
   Drawer close layout hard fix v2
   - 닫힌 상태에서 drawer가 grid item으로 남아 차트/오른쪽 패널이 밀리는 문제 방지
   - 원인: .bv-left-panel.bv-tool-drawer가 display:flex !important 상태로 남아 grid 첫 칸을 계속 차지함
   ========================================================= */
.bitgak-chart-body .bv-layout:not(.bv-drawer-open),
.bitgak-chart-body .bv-layout-full:not(.bv-drawer-open) {
  grid-template-columns: minmax(0, 1fr) 320px !important;
  grid-template-rows: minmax(0, 1fr) !important;
  align-items: stretch !important;
}

.bitgak-chart-body .bv-layout:not(.bv-drawer-open) > .bv-left-panel.bv-tool-drawer,
.bitgak-chart-body .bv-layout-full:not(.bv-drawer-open) > .bv-left-panel.bv-tool-drawer {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateX(-18px) !important;
}

.bitgak-chart-body .bv-layout:not(.bv-drawer-open) > .bv-main,
.bitgak-chart-body .bv-layout-full:not(.bv-drawer-open) > .bv-main {
  grid-column: 1 / 2 !important;
  grid-row: 1 / 2 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: 100% !important;
  padding: 14px 8px 14px 14px !important;
}

.bitgak-chart-body .bv-layout:not(.bv-drawer-open) > .bv-symbol-panel,
.bitgak-chart-body .bv-layout-full:not(.bv-drawer-open) > .bv-symbol-panel {
  grid-column: 2 / 3 !important;
  grid-row: 1 / 2 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: 100% !important;
  display: grid !important;
}

.bitgak-chart-body .bv-layout.bv-drawer-open,
.bitgak-chart-body .bv-layout-full.bv-drawer-open {
  grid-template-columns: 450px minmax(520px, 1fr) 320px !important;
  grid-template-rows: minmax(0, 1fr) !important;
}

.bitgak-chart-body .bv-layout.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
.bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-left-panel.bv-tool-drawer {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateX(0) !important;
  grid-column: 1 / 2 !important;
  grid-row: 1 / 2 !important;
  min-height: 0 !important;
  height: 100% !important;
}

.bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
.bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
  grid-column: 2 / 3 !important;
  grid-row: 1 / 2 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: 100% !important;
  padding: 14px 8px 14px 0 !important;
}

.bitgak-chart-body .bv-layout.bv-drawer-open > .bv-symbol-panel,
.bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-symbol-panel {
  grid-column: 3 / 4 !important;
  grid-row: 1 / 2 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: 100% !important;
  display: grid !important;
}

@media (max-width: 1450px) {
  .bitgak-chart-body .bv-layout:not(.bv-drawer-open),
  .bitgak-chart-body .bv-layout-full:not(.bv-drawer-open) {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .bitgak-chart-body .bv-layout:not(.bv-drawer-open) > .bv-main,
  .bitgak-chart-body .bv-layout-full:not(.bv-drawer-open) > .bv-main {
    grid-column: 1 / 2 !important;
    padding: 14px !important;
  }

  .bitgak-chart-body .bv-layout:not(.bv-drawer-open) > .bv-symbol-panel,
  .bitgak-chart-body .bv-layout-full:not(.bv-drawer-open) > .bv-symbol-panel {
    display: none !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open {
    grid-template-columns: 430px minmax(0, 1fr) !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
    grid-column: 2 / 3 !important;
    padding: 14px 14px 14px 0 !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-symbol-panel,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-symbol-panel {
    display: none !important;
  }
}

@media (max-width: 1120px) {
  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full,
  .bitgak-chart-body .bv-layout.bv-drawer-open,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .bitgak-chart-body .bv-layout > .bv-main,
  .bitgak-chart-body .bv-layout-full > .bv-main,
  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
    grid-column: 1 / 2 !important;
    padding: 10px !important;
  }

  .bitgak-chart-body .bv-layout > .bv-symbol-panel,
  .bitgak-chart-body .bv-layout-full > .bv-symbol-panel {
    display: none !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer {
    position: fixed !important;
    left: 10px !important;
    top: 86px !important;
    bottom: 12px !important;
    width: min(430px, calc(100vw - 20px)) !important;
    z-index: 9000 !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer:not(.open) {
    display: none !important;
  }
}

/* =========================================================
   Portfolio drawer smooth toggle v3
   - 닫기 버튼뿐 아니라 상단 평단가/포트폴리오 버튼 재클릭 시 닫힘
   - drawer는 display:none으로 즉시 사라지지 않고 0px column으로 부드럽게 접힘
   - 보유종목 목록은 길어지면 내부 스크롤
   ========================================================= */
.bitgak-chart-body .bv-layout,
.bitgak-chart-body .bv-layout-full {
  display: grid !important;
  grid-template-columns: 0 minmax(0, 1fr) 320px !important;
  grid-template-rows: minmax(0, 1fr) !important;
  column-gap: 0 !important;
  transition:
    grid-template-columns 520ms cubic-bezier(.22, .72, .18, 1),
    column-gap 520ms cubic-bezier(.22, .72, .18, 1) !important;
  will-change: grid-template-columns;
}

.bitgak-chart-body .bv-layout.bv-drawer-open,
.bitgak-chart-body .bv-layout-full.bv-drawer-open {
  grid-template-columns: 450px minmax(520px, 1fr) 320px !important;
  column-gap: 12px !important;
}

.bitgak-chart-body .bv-layout > .bv-left-panel.bv-tool-drawer,
.bitgak-chart-body .bv-layout-full > .bv-left-panel.bv-tool-drawer {
  display: flex !important;
  grid-column: 1 / 2 !important;
  grid-row: 1 / 2 !important;
  min-width: 0 !important;
  width: 100% !important;
  max-width: 450px !important;
  height: 100% !important;
  min-height: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateX(-34px) scaleX(.985) !important;
  transform-origin: left center !important;
  transition:
    opacity 440ms ease,
    transform 520ms cubic-bezier(.22, .72, .18, 1),
    visibility 0s linear 520ms !important;
  will-change: opacity, transform;
}

.bitgak-chart-body .bv-layout.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
.bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
.bitgak-chart-body .bv-left-panel.bv-tool-drawer.open {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateX(0) scaleX(1) !important;
  transition:
    opacity 460ms ease,
    transform 520ms cubic-bezier(.22, .72, .18, 1),
    visibility 0s linear 0s !important;
}

.bitgak-chart-body .bv-layout > .bv-main,
.bitgak-chart-body .bv-layout-full > .bv-main {
  grid-column: 2 / 3 !important;
  grid-row: 1 / 2 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: 100% !important;
  padding: 14px 8px 14px 14px !important;
  transition: padding 520ms cubic-bezier(.22, .72, .18, 1) !important;
}

.bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
.bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
  padding: 14px 8px 14px 0 !important;
}

.bitgak-chart-body .bv-layout > .bv-symbol-panel,
.bitgak-chart-body .bv-layout-full > .bv-symbol-panel {
  grid-column: 3 / 4 !important;
  grid-row: 1 / 2 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: 100% !important;
  display: grid !important;
}

.bitgak-chart-body .bv-tool-drawer {
  flex-direction: column !important;
  max-height: 100% !important;
}

.bitgak-chart-body .bv-drawer-view {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  scrollbar-gutter: stable;
}

.bitgak-chart-body .portfolio-panel.active {
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
}

.bitgak-chart-body .portfolio-summary-card strong#portfolioProfit {
  font-size: 20px;
  letter-spacing: -0.04em;
}

.bitgak-chart-body .portfolio-holdings-card {
  flex: 1 1 auto;
  min-height: 180px;
  display: flex;
  flex-direction: column;
}

.bitgak-chart-body .portfolio-holding-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(330px, 32vh);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.bitgak-chart-body .portfolio-holding-list::-webkit-scrollbar,
.bitgak-chart-body .bv-drawer-view::-webkit-scrollbar {
  width: 8px;
}

.bitgak-chart-body .portfolio-holding-list::-webkit-scrollbar-thumb,
.bitgak-chart-body .bv-drawer-view::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(148, 163, 184, .38);
}

.bitgak-chart-body .portfolio-holding-list::-webkit-scrollbar-track,
.bitgak-chart-body .bv-drawer-view::-webkit-scrollbar-track {
  background: rgba(2, 6, 23, .16);
  border-radius: 999px;
}

@media (max-width: 1450px) {
  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full {
    grid-template-columns: 0 minmax(0, 1fr) !important;
    column-gap: 0 !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open {
    grid-template-columns: 430px minmax(0, 1fr) !important;
    column-gap: 12px !important;
  }

  .bitgak-chart-body .bv-layout > .bv-symbol-panel,
  .bitgak-chart-body .bv-layout-full > .bv-symbol-panel {
    display: none !important;
  }

  .bitgak-chart-body .bv-layout > .bv-main,
  .bitgak-chart-body .bv-layout-full > .bv-main {
    grid-column: 2 / 3 !important;
    padding: 14px !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
    padding: 14px 14px 14px 0 !important;
  }
}

@media (max-width: 1120px) {
  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full,
  .bitgak-chart-body .bv-layout.bv-drawer-open,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open {
    grid-template-columns: minmax(0, 1fr) !important;
    column-gap: 0 !important;
  }

  .bitgak-chart-body .bv-layout > .bv-main,
  .bitgak-chart-body .bv-layout-full > .bv-main,
  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
    grid-column: 1 / 2 !important;
    padding: 10px !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer {
    position: fixed !important;
    left: 10px !important;
    top: 86px !important;
    bottom: 12px !important;
    width: min(430px, calc(100vw - 20px)) !important;
    max-width: min(430px, calc(100vw - 20px)) !important;
    z-index: 9000 !important;
  }
}

/* =========================================================
   Drawer overlay motion v3 - chart stays fixed
   - drawer는 grid column을 차지하지 않고 왼쪽에서 overlay로 열린다.
   - 차트/오른쪽 패널은 토글 시 좌우로 밀리지 않는다.
   - 느린 cubic-bezier로 스르륵 열린다.
   ========================================================= */
.bitgak-chart-body .bv-layout,
.bitgak-chart-body .bv-layout-full {
  position: relative !important;
  grid-template-columns: minmax(620px, 1fr) 320px !important;
  transition: none !important;
  overflow: hidden !important;
}

.bitgak-chart-body .bv-layout.bv-drawer-open,
.bitgak-chart-body .bv-layout-full.bv-drawer-open {
  grid-template-columns: minmax(620px, 1fr) 320px !important;
}

.bitgak-chart-body .bv-left-panel.bv-tool-drawer {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  z-index: 80 !important;
  width: 450px !important;
  max-width: min(450px, calc(100vw - 28px)) !important;
  display: flex !important;
  min-width: 0 !important;
  padding: 0 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateX(-108%) scale(0.992) !important;
  filter: blur(2px);
  will-change: transform, opacity, filter;
  transition:
    transform 980ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 760ms ease,
    filter 980ms ease,
    visibility 0s linear 980ms !important;
}

.bitgak-chart-body .bv-layout.bv-drawer-open .bv-left-panel.bv-tool-drawer,
.bitgak-chart-body .bv-layout-full.bv-drawer-open .bv-left-panel.bv-tool-drawer,
.bitgak-chart-body .bv-left-panel.bv-tool-drawer.open,
.bitgak-chart-body .bv-left-panel.bv-tool-drawer.bv-drawer-closing {
  visibility: visible !important;
}

.bitgak-chart-body .bv-layout.bv-drawer-open .bv-left-panel.bv-tool-drawer,
.bitgak-chart-body .bv-layout-full.bv-drawer-open .bv-left-panel.bv-tool-drawer,
.bitgak-chart-body .bv-left-panel.bv-tool-drawer.open {
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateX(0) scale(1) !important;
  filter: blur(0);
  transition:
    transform 980ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 760ms ease,
    filter 980ms ease,
    visibility 0s !important;
}

.bitgak-chart-body .bv-left-panel.bv-tool-drawer.bv-drawer-closing {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateX(-108%) scale(0.992) !important;
  filter: blur(2px);
}

@media (max-width: 1450px) {
  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full,
  .bitgak-chart-body .bv-layout.bv-drawer-open,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .bitgak-chart-body .bv-symbol-panel {
    display: none !important;
  }
}

@media (max-width: 1120px) {
  .bitgak-chart-body .bv-left-panel.bv-tool-drawer {
    position: fixed !important;
    left: 10px !important;
    top: 86px !important;
    bottom: 12px !important;
    width: min(430px, calc(100vw - 20px)) !important;
    z-index: 9000 !important;
  }
}

/* =========================================================
   Drawer final fix v4
   - 이전 grid 3열 / 0px column 규칙을 최종 override
   - drawer는 absolute overlay
   - 메인 차트는 항상 1번 column, 오른쪽 패널은 2번 column
   - drawer open 시 메인 차트의 왼쪽 padding만 천천히 늘어나서 오른쪽 기준은 유지됨
   ========================================================= */
.bitgak-chart-body {
  --bv-drawer-width: 450px;
  --bv-drawer-gap: 12px;
  --bv-drawer-motion: 1450ms;
  --bv-drawer-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

.bitgak-chart-body .bv-layout,
.bitgak-chart-body .bv-layout-full {
  position: relative !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 320px !important;
  grid-template-rows: minmax(0, 1fr) !important;
  column-gap: 12px !important;
  overflow: hidden !important;
  align-items: stretch !important;
  transition: none !important;
}

/* drawer는 grid flow에서 완전히 빼서 차트/우측패널을 밀지 않게 한다 */
.bitgak-chart-body .bv-layout > .bv-left-panel.bv-tool-drawer,
.bitgak-chart-body .bv-layout-full > .bv-left-panel.bv-tool-drawer {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  z-index: 90 !important;
  grid-column: auto !important;
  grid-row: auto !important;
  width: var(--bv-drawer-width) !important;
  max-width: min(var(--bv-drawer-width), calc(100vw - 28px)) !important;
  height: 100% !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateX(calc(-100% - 18px)) scale(0.985) !important;
  filter: blur(2px);
  transform-origin: left center !important;
  will-change: transform, opacity, filter;
  transition:
    transform var(--bv-drawer-motion) var(--bv-drawer-ease),
    opacity 1050ms ease,
    filter var(--bv-drawer-motion) ease,
    visibility 0s linear var(--bv-drawer-motion) !important;
}

.bitgak-chart-body .bv-layout.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
.bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
.bitgak-chart-body .bv-left-panel.bv-tool-drawer.open {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateX(0) scale(1) !important;
  filter: blur(0);
  transition:
    transform var(--bv-drawer-motion) var(--bv-drawer-ease),
    opacity 1050ms ease,
    filter var(--bv-drawer-motion) ease,
    visibility 0s linear 0s !important;
}

.bitgak-chart-body .bv-left-panel.bv-tool-drawer.bv-drawer-closing {
  visibility: visible !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateX(calc(-100% - 18px)) scale(0.985) !important;
  filter: blur(2px);
}

/* 핵심: main은 항상 1번 column. 이전 CSS의 grid-column:2/3를 무력화 */
.bitgak-chart-body .bv-layout > .bv-main,
.bitgak-chart-body .bv-layout-full > .bv-main,
.bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
.bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
  grid-column: 1 / 2 !important;
  grid-row: 1 / 2 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: 100% !important;
  padding-top: 14px !important;
  padding-right: 0 !important;
  padding-bottom: 14px !important;
  padding-left: 14px !important;
  transition:
    padding-left var(--bv-drawer-motion) var(--bv-drawer-ease),
    padding-right var(--bv-drawer-motion) var(--bv-drawer-ease) !important;
  will-change: padding-left;
}

/* 열렸을 때 오른쪽 기준은 유지하고 왼쪽 영역만 drawer 폭만큼 비워서 차트가 부드럽게 줄어든다 */
.bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
.bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
  padding-left: calc(var(--bv-drawer-width) + var(--bv-drawer-gap)) !important;
}

/* 오른쪽 패널은 항상 2번 column */
.bitgak-chart-body .bv-layout > .bv-symbol-panel,
.bitgak-chart-body .bv-layout-full > .bv-symbol-panel,
.bitgak-chart-body .bv-layout.bv-drawer-open > .bv-symbol-panel,
.bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-symbol-panel {
  grid-column: 2 / 3 !important;
  grid-row: 1 / 2 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: 100% !important;
  display: grid !important;
}

/* drawer 내부 스크롤 안정화 */
.bitgak-chart-body .bv-left-panel.bv-tool-drawer .bv-drawer-view {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  scrollbar-gutter: stable;
}

.bitgak-chart-body .portfolio-holding-list {
  max-height: min(330px, 32vh) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain !important;
}

/* 중간 화면에서는 오른쪽 패널을 숨기고 차트만 유지 */
@media (max-width: 1450px) {
  .bitgak-chart-body {
    --bv-drawer-width: 430px;
  }

  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full,
  .bitgak-chart-body .bv-layout.bv-drawer-open,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open {
    grid-template-columns: minmax(0, 1fr) !important;
    column-gap: 0 !important;
  }

  .bitgak-chart-body .bv-layout > .bv-symbol-panel,
  .bitgak-chart-body .bv-layout-full > .bv-symbol-panel,
  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-symbol-panel,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-symbol-panel {
    display: none !important;
  }
}

@media (max-width: 1120px) {
  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main,
  .bitgak-chart-body .bv-layout > .bv-main,
  .bitgak-chart-body .bv-layout-full > .bv-main {
    padding: 10px !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer {
    position: fixed !important;
    left: 10px !important;
    top: 86px !important;
    bottom: 12px !important;
    width: min(430px, calc(100vw - 20px)) !important;
    max-width: min(430px, calc(100vw - 20px)) !important;
    z-index: 9000 !important;
  }
}



/* =========================================================
   Mobile header + chart top layout fix v2
   - 모바일 1행: 로고 / 검색 / 로그인
   - 모바일 2행: 평단가 계산기 / 포트폴리오
   - 차트 상단 버튼/그리기툴/OHLC가 겹치지 않도록 고정 정렬
   ========================================================= */
@media (max-width: 760px) {
  .bitgak-chart-body .bv-app {
    grid-template-rows: 106px minmax(0, 1fr) !important;
    height: 100vh !important;
    min-height: 0 !important;
  }

  .bitgak-chart-body .bv-header {
    height: 106px !important;
    min-height: 106px !important;
    padding: 7px 10px 8px !important;
    display: grid !important;
    grid-template-columns: 34px minmax(0, 1fr) auto !important;
    grid-template-rows: 40px 40px !important;
    align-items: center !important;
    gap: 8px !important;
    overflow: visible !important;
  }

  .bitgak-chart-body .bv-logo-area {
    grid-column: 1 / 2 !important;
    grid-row: 1 / 2 !important;
    min-width: 0 !important;
  }

  .bitgak-chart-body .bv-logo {
    width: 30px !important;
    height: 30px !important;
    border-radius: 11px !important;
    font-size: 13px !important;
  }

  .bitgak-chart-body .bv-brand {
    display: none !important;
  }

  .bitgak-chart-body .bv-search,
  .bitgak-chart-body .bv-search-live {
    grid-column: 2 / 3 !important;
    grid-row: 1 / 2 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 38px !important;
    margin: 0 !important;
  }

  .bitgak-chart-body .bv-search input {
    min-width: 0 !important;
    padding-left: 14px !important;
    padding-right: 8px !important;
    font-size: 13px !important;
  }

  .bitgak-chart-body .bv-search button {
    flex-basis: 34px !important;
    width: 34px !important;
  }

  .bitgak-chart-body .bv-header-actions {
    grid-column: 3 / 4 !important;
    grid-row: 1 / 2 !important;
    display: flex !important;
    margin-left: 0 !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 0 !important;
    min-width: 0 !important;
  }

  .bitgak-chart-body .bv-header-actions a,
  .bitgak-chart-body .bv-header-actions button {
    height: 38px !important;
    min-width: 58px !important;
    padding: 0 11px !important;
    border-radius: 14px !important;
    font-size: 12px !important;
    font-weight: 1000 !important;
    white-space: nowrap !important;
  }

  .bitgak-chart-body .bv-drawer-actions {
    grid-column: 1 / 4 !important;
    grid-row: 2 / 3 !important;
    width: 100% !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 8px !important;
    order: initial !important;
    margin: 0 !important;
  }

  .bitgak-chart-body .bv-drawer-action-btn {
    width: 100% !important;
    height: 40px !important;
    padding: 0 10px !important;
    border-radius: 14px !important;
    font-size: 13px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full,
  .bitgak-chart-body .bv-layout.bv-drawer-open,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open {
    grid-row: 2 / 3 !important;
    height: calc(100vh - 106px) !important;
    min-height: 0 !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .bitgak-chart-body .bv-layout > .bv-main,
  .bitgak-chart-body .bv-layout-full > .bv-main,
  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
    padding: 7px 8px 8px !important;
    min-height: 0 !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer {
    top: 116px !important;
    left: 8px !important;
    right: auto !important;
    bottom: 10px !important;
    width: min(430px, calc(100vw - 16px)) !important;
    max-width: min(430px, calc(100vw - 16px)) !important;
  }

  .bitgak-chart-body .chart-card,
  .bitgak-chart-body .chart-card-full {
    min-height: 0 !important;
    border-radius: 12px !important;
  }

  .bitgak-chart-body .chart-card-top {
    flex: 0 0 auto !important;
    min-height: 116px !important;
    height: auto !important;
    padding: 8px 9px 7px !important;
    display: grid !important;
    grid-template-columns: auto auto auto minmax(0, 1fr) !important;
    grid-template-rows: 22px 32px 34px !important;
    grid-template-areas:
      "title title title title"
      "interval search active ."
      "tools tools tools tools" !important;
    align-items: center !important;
    gap: 7px 8px !important;
    overflow: visible !important;
    z-index: 80 !important;
  }

  .bitgak-chart-body .chart-title {
    grid-area: title !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .bitgak-chart-body .tv-interval-dropdown {
    grid-area: interval !important;
    align-self: center !important;
    justify-self: start !important;
    z-index: 160 !important;
  }

  .bitgak-chart-body #openIndicatorBtn {
    grid-area: search !important;
    align-self: center !important;
    justify-self: start !important;
  }

  .bitgak-chart-body #openMobileIndicatorsBtn {
    grid-area: active !important;
    align-self: center !important;
    justify-self: start !important;
  }

  .bitgak-chart-body .tv-interval-btn,
  .bitgak-chart-body .chart-top-btn {
    height: 32px !important;
    min-height: 32px !important;
    border-radius: 11px !important;
    font-size: 12px !important;
    padding: 0 10px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  .bitgak-chart-body .tv-interval-btn {
    min-width: 72px !important;
  }

  .bitgak-chart-body #openIndicatorBtn {
    min-width: 72px !important;
  }

  .bitgak-chart-body #openMobileIndicatorsBtn {
    min-width: 92px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
  }

  .bitgak-chart-body .mobile-active-indicator-badge {
    min-width: 20px !important;
    height: 20px !important;
    padding: 0 6px !important;
    font-size: 10px !important;
  }

  .bitgak-chart-body .bv-drawing-toolbar {
    grid-area: tools !important;
    order: initial !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 34px !important;
    margin: 0 !important;
    padding: 3px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    justify-content: flex-start !important;
    background: rgba(15, 23, 42, 0.04) !important;
  }

  .bitgak-chart-body .tool-btn {
    width: 28px !important;
    height: 28px !important;
    flex: 0 0 28px !important;
  }

  .bitgak-chart-body .chart-top-spacer,
  .bitgak-chart-body .chart-mode-text {
    display: none !important;
  }

  .bitgak-chart-body .ohlc-info {
    flex: 0 0 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    padding: 10px 10px 0 !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    position: relative !important;
    z-index: 50 !important;
    border-top: 1px solid #eef2f7 !important;
    border-bottom: 1px solid #e5edf6 !important;
    background: #ffffff !important;
  }

  .bitgak-chart-body .chart-wrap,
  .bitgak-chart-body .chart-wrap-v5 {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .bitgak-chart-body .stock-search-panel {
    top: calc(100% + 8px) !important;
    left: -42px !important;
    width: calc(100vw - 20px) !important;
    max-height: min(430px, calc(100vh - 132px)) !important;
    z-index: 100000 !important;
  }
}

@media (max-width: 420px) {
  .bitgak-chart-body .bv-header {
    grid-template-columns: 32px minmax(0, 1fr) auto !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
    gap: 7px !important;
  }

  .bitgak-chart-body .bv-header-actions a,
  .bitgak-chart-body .bv-header-actions button {
    min-width: 54px !important;
    padding: 0 9px !important;
    font-size: 11px !important;
  }

  .bitgak-chart-body .chart-card-top {
    grid-template-columns: auto auto auto minmax(0, 1fr) !important;
    gap: 7px 6px !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .bitgak-chart-body .tv-interval-btn,
  .bitgak-chart-body .chart-top-btn {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .bitgak-chart-body #openMobileIndicatorsBtn {
    min-width: 86px !important;
  }
}

/* =========================================================
   Mobile modal balance fix v3
   - 모바일 평단가/포트폴리오는 차트 레이아웃을 밀지 않는 중앙 모달
   - 상단 1행/2행/차트 사이 간격 8px 기준으로 정렬
   - 적용지표 모달은 바텀시트가 아니라 위쪽 모달로 표시
   ========================================================= */
@media (max-width: 760px) {
  .bitgak-chart-body .bv-app {
    grid-template-rows: 100px minmax(0, 1fr) !important;
  }

  .bitgak-chart-body .bv-header {
    height: 100px !important;
    min-height: 100px !important;
    padding: 8px 10px !important;
    grid-template-columns: 32px minmax(0, 1fr) 58px !important;
    grid-template-rows: 38px 38px !important;
    gap: 8px !important;
  }

  .bitgak-chart-body .bv-logo {
    width: 30px !important;
    height: 30px !important;
    border-radius: 11px !important;
  }

  .bitgak-chart-body .bv-search,
  .bitgak-chart-body .bv-search-live {
    width: min(100%, 276px) !important;
    max-width: 276px !important;
    height: 38px !important;
    justify-self: start !important;
  }

  .bitgak-chart-body .bv-search input {
    padding-left: 13px !important;
    padding-right: 6px !important;
    font-size: 12px !important;
  }

  .bitgak-chart-body .bv-search button {
    flex: 0 0 32px !important;
    width: 32px !important;
  }

  .bitgak-chart-body .bv-header-actions {
    width: 58px !important;
    justify-self: end !important;
  }

  .bitgak-chart-body .bv-header-actions a,
  .bitgak-chart-body .bv-header-actions button {
    width: 58px !important;
    min-width: 58px !important;
    height: 38px !important;
    padding: 0 !important;
    border-radius: 13px !important;
    font-size: 11px !important;
  }

  .bitgak-chart-body .bv-drawer-actions {
    gap: 8px !important;
  }

  .bitgak-chart-body .bv-drawer-action-btn {
    height: 38px !important;
    border-radius: 14px !important;
  }

  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full,
  .bitgak-chart-body .bv-layout.bv-drawer-open,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open {
    height: calc(100vh - 100px) !important;
    height: calc(100dvh - 100px) !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    position: relative !important;
  }

  .bitgak-chart-body .bv-layout > .bv-main,
  .bitgak-chart-body .bv-layout-full > .bv-main,
  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
    grid-column: 1 / 2 !important;
    grid-row: 1 / 2 !important;
    padding: 8px !important;
    transform: none !important;
    transition: none !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open::before,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 10900;
    background: rgba(2, 6, 23, 0.62);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer {
    position: fixed !important;
    top: calc(50% + 20px) !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    width: min(390px, calc(100vw - 26px)) !important;
    max-width: min(390px, calc(100vw - 26px)) !important;
    height: auto !important;
    max-height: calc(100vh - 132px) !important;
    max-height: calc(100dvh - 132px) !important;
    padding: 0 !important;
    border-radius: 24px !important;
    overflow: hidden !important;
    z-index: 11000 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translate(-50%, -50%) scale(0.985) !important;
    transition: opacity .18s ease, transform .18s ease, visibility .18s ease !important;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.60) !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
  .bitgak-chart-body .bv-left-panel.bv-tool-drawer.open,
  .bitgak-chart-body .bv-left-panel.bv-tool-drawer.bv-drawer-closing {
    display: flex !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
  .bitgak-chart-body .bv-left-panel.bv-tool-drawer.open {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translate(-50%, -50%) scale(1) !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer.bv-drawer-closing {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translate(-50%, -50%) scale(0.985) !important;
  }

  .bitgak-chart-body .bv-tool-drawer-head {
    padding: 16px 16px 12px !important;
  }

  .bitgak-chart-body .bv-tool-drawer-tabs {
    margin: 0 14px 12px !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer .bv-drawer-view {
    padding: 0 14px 14px !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
  }

  .bitgak-chart-body .avg-calc-card,
  .bitgak-chart-body .portfolio-panel {
    border-radius: 18px !important;
  }

  .bitgak-chart-body .mobile-indicator-modal {
    align-items: flex-start !important;
    justify-content: center !important;
    padding: max(86px, env(safe-area-inset-top)) 12px 16px !important;
  }

  .bitgak-chart-body .mobile-indicator-panel {
    width: min(390px, calc(100vw - 24px)) !important;
    max-height: min(70vh, 560px) !important;
    max-height: min(70dvh, 560px) !important;
    border-radius: 24px !important;
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58) !important;
  }
}

@media (max-width: 420px) {
  .bitgak-chart-body .bv-header {
    grid-template-columns: 32px minmax(0, 1fr) 56px !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .bitgak-chart-body .bv-search,
  .bitgak-chart-body .bv-search-live {
    max-width: 258px !important;
  }

  .bitgak-chart-body .bv-header-actions,
  .bitgak-chart-body .bv-header-actions a,
  .bitgak-chart-body .bv-header-actions button {
    width: 56px !important;
    min-width: 56px !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
  }
}

@media (max-width: 380px) {
  .bitgak-chart-body .bv-search,
  .bitgak-chart-body .bv-search-live {
    max-width: 236px !important;
  }

  .bitgak-chart-body .bv-search input {
    font-size: 11px !important;
  }
}

/* =========================================================
   Mobile spacing + modal stacking + touch crosshair final v4
   - 모바일 헤더/버튼/차트 간격 8px 기준 정렬
   - 평단가/포트폴리오 모달이 블러 뒤로 숨지 않도록 z-index 스택 고정
   - 검색/로그인/도구 버튼 폭 균형 조정
   ========================================================= */
@media (max-width: 760px) {
  .bitgak-chart-body .bv-app {
    grid-template-rows: 108px minmax(0, 1fr) !important;
  }

  .bitgak-chart-body .bv-header {
    height: 108px !important;
    min-height: 108px !important;
    padding: 8px 10px 10px !important;
    grid-template-columns: 32px minmax(0, 1fr) 58px !important;
    grid-template-rows: 38px 40px !important;
    column-gap: 8px !important;
    row-gap: 8px !important;
  }

  .bitgak-chart-body .bv-search,
  .bitgak-chart-body .bv-search-live {
    width: 100% !important;
    max-width: none !important;
    height: 38px !important;
  }

  .bitgak-chart-body .bv-search input {
    padding-left: 13px !important;
    padding-right: 4px !important;
    font-size: 12px !important;
  }

  .bitgak-chart-body .bv-search button {
    flex: 0 0 32px !important;
    width: 32px !important;
  }

  .bitgak-chart-body .bv-header-actions,
  .bitgak-chart-body .bv-header-actions a,
  .bitgak-chart-body .bv-header-actions button {
    width: 58px !important;
    min-width: 58px !important;
  }

  .bitgak-chart-body .bv-drawer-actions {
    height: 40px !important;
    gap: 8px !important;
  }

  .bitgak-chart-body .bv-drawer-action-btn {
    height: 40px !important;
    min-height: 40px !important;
    border-radius: 14px !important;
  }

  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full,
  .bitgak-chart-body .bv-layout.bv-drawer-open,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open {
    height: calc(100vh - 108px) !important;
    height: calc(100dvh - 108px) !important;
    isolation: isolate !important;
  }

  .bitgak-chart-body .bv-layout > .bv-main,
  .bitgak-chart-body .bv-layout-full > .bv-main,
  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
    padding: 8px 10px 10px !important;
    transform: none !important;
    transition: none !important;
  }

  .bitgak-chart-body .chart-card,
  .bitgak-chart-body .chart-card-full {
    border-radius: 12px !important;
  }

  .bitgak-chart-body .chart-card-top {
    min-height: 116px !important;
    padding: 8px 9px 7px !important;
  }

  .bitgak-chart-body .ohlc-info {
    flex-basis: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
  }

  .bitgak-chart-body .stock-search-panel {
    left: -40px !important;
    width: calc(100vw - 20px) !important;
    max-width: calc(100vw - 20px) !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open::before,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open::before {
    z-index: 2147482000 !important;
    background: rgba(2, 6, 23, 0.58) !important;
    backdrop-filter: blur(7px) !important;
    -webkit-backdrop-filter: blur(7px) !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer {
    top: calc(50% + 12px) !important;
    left: 50% !important;
    width: min(390px, calc(100vw - 24px)) !important;
    max-width: min(390px, calc(100vw - 24px)) !important;
    max-height: calc(100vh - 126px) !important;
    max-height: calc(100dvh - 126px) !important;
    z-index: 2147483000 !important;
    transform: translate(-50%, -50%) scale(0.985) !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
  .bitgak-chart-body .bv-left-panel.bv-tool-drawer.open {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translate(-50%, -50%) scale(1) !important;
    z-index: 2147483000 !important;
  }

  .bitgak-chart-body .mobile-indicator-modal {
    align-items: flex-start !important;
    padding: max(70px, env(safe-area-inset-top)) 12px 16px !important;
  }

  .bitgak-chart-body .mobile-indicator-panel {
    max-height: min(74vh, 590px) !important;
    max-height: min(74dvh, 590px) !important;
  }
}

@media (max-width: 420px) {
  .bitgak-chart-body .bv-header {
    grid-template-columns: 32px minmax(0, 1fr) 56px !important;
    padding-left: 9px !important;
    padding-right: 9px !important;
  }

  .bitgak-chart-body .bv-header-actions,
  .bitgak-chart-body .bv-header-actions a,
  .bitgak-chart-body .bv-header-actions button {
    width: 56px !important;
    min-width: 56px !important;
  }

  .bitgak-chart-body .bv-layout > .bv-main,
  .bitgak-chart-body .bv-layout-full > .bv-main,
  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
    padding-left: 9px !important;
    padding-right: 9px !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer {
    width: calc(100vw - 22px) !important;
    max-width: calc(100vw - 22px) !important;
  }
}

/* =========================================================
   Mobile final alignment v5
   - 헤더 버튼줄과 차트 카드 사이 여백 축소
   - 평단가/포트폴리오 모달을 모바일 레이아웃 내부 기준으로 정렬
   - 적용지표 창/지표검색 열기 버튼 크기 보강
   ========================================================= */
@media (max-width: 760px) {
  .bitgak-chart-body .bv-app {
    grid-template-rows: 108px minmax(0, 1fr) !important;
  }

  .bitgak-chart-body .bv-header {
    height: 108px !important;
    min-height: 108px !important;
    padding: 8px 10px 8px !important;
    grid-template-columns: 32px minmax(0, 1fr) 60px !important;
    grid-template-rows: 38px 40px !important;
    column-gap: 8px !important;
    row-gap: 8px !important;
    align-content: start !important;
  }

  .bitgak-chart-body .bv-logo-area,
  .bitgak-chart-body .bv-header-actions,
  .bitgak-chart-body .bv-search,
  .bitgak-chart-body .bv-search-live,
  .bitgak-chart-body .bv-drawer-actions {
    align-self: center !important;
  }

  .bitgak-chart-body .bv-search,
  .bitgak-chart-body .bv-search-live {
    width: 100% !important;
    max-width: none !important;
    height: 38px !important;
  }

  .bitgak-chart-body .bv-search input {
    font-size: 12px !important;
    padding-left: 13px !important;
    padding-right: 4px !important;
  }

  .bitgak-chart-body .bv-search button {
    flex: 0 0 32px !important;
    width: 32px !important;
  }

  .bitgak-chart-body .bv-header-actions,
  .bitgak-chart-body .bv-header-actions a,
  .bitgak-chart-body .bv-header-actions button {
    width: 60px !important;
    min-width: 60px !important;
    height: 38px !important;
  }

  .bitgak-chart-body .bv-drawer-actions {
    height: 40px !important;
    gap: 8px !important;
  }

  .bitgak-chart-body .bv-drawer-action-btn {
    height: 40px !important;
    min-height: 40px !important;
    border-radius: 14px !important;
  }

  .bitgak-chart-body .bv-layout,
  .bitgak-chart-body .bv-layout-full,
  .bitgak-chart-body .bv-layout.bv-drawer-open,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open {
    height: calc(100vh - 108px) !important;
    height: calc(100dvh - 108px) !important;
    position: relative !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    column-gap: 0 !important;
    transition: none !important;
    overflow: hidden !important;
  }

  .bitgak-chart-body .bv-layout > .bv-main,
  .bitgak-chart-body .bv-layout-full > .bv-main,
  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
    grid-column: 1 / 2 !important;
    grid-row: 1 / 2 !important;
    height: 100% !important;
    min-height: 0 !important;
    padding: 4px 10px 8px !important;
    transform: none !important;
    transition: none !important;
  }

  .bitgak-chart-body .chart-card,
  .bitgak-chart-body .chart-card-full {
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    border-radius: 12px !important;
  }

  .bitgak-chart-body .chart-card-top {
    min-height: 114px !important;
    padding: 8px 9px 7px !important;
    grid-template-rows: 22px 33px 34px !important;
    gap: 7px 8px !important;
  }

  .bitgak-chart-body #openIndicatorBtn {
    min-width: 82px !important;
    height: 33px !important;
    padding: 0 12px !important;
    font-size: 12px !important;
  }

  .bitgak-chart-body #openMobileIndicatorsBtn {
    min-width: 98px !important;
    height: 33px !important;
    padding: 0 10px !important;
  }

  .bitgak-chart-body .tv-interval-btn {
    height: 33px !important;
    min-width: 72px !important;
  }

  .bitgak-chart-body .bv-drawing-toolbar {
    height: 34px !important;
    border-radius: 14px !important;
  }

  .bitgak-chart-body .ohlc-info {
    flex: 0 0 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 9px 10px 0 !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open::before,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open::before {
    content: "" !important;
    position: absolute !important;
    inset: 0 !important;
    z-index: 2147482000 !important;
    background: rgba(2, 6, 23, 0.58) !important;
    backdrop-filter: blur(7px) !important;
    -webkit-backdrop-filter: blur(7px) !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer {
    position: absolute !important;
    top: 8px !important;
    left: 50% !important;
    right: auto !important;
    bottom: 8px !important;
    width: min(392px, calc(100% - 20px)) !important;
    max-width: min(392px, calc(100% - 20px)) !important;
    height: auto !important;
    max-height: none !important;
    min-width: 0 !important;
    padding: 0 !important;
    border-radius: 24px !important;
    overflow: hidden !important;
    z-index: 2147483000 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateX(-50%) scale(0.985) !important;
    transform-origin: center center !important;
    transition: opacity .18s ease, transform .18s ease, visibility .18s ease !important;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.60) !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
  .bitgak-chart-body .bv-left-panel.bv-tool-drawer.open {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateX(-50%) scale(1) !important;
    grid-column: auto !important;
    grid-row: auto !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer.bv-drawer-closing {
    display: flex !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateX(-50%) scale(0.985) !important;
  }

  .bitgak-chart-body .bv-tool-drawer-head {
    padding: 16px 16px 12px !important;
  }

  .bitgak-chart-body .bv-tool-drawer-tabs {
    margin: 0 14px 12px !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer .bv-drawer-view {
    min-width: 0 !important;
    padding: 0 14px 14px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
  }

  .bitgak-chart-body .avg-calc-card,
  .bitgak-chart-body .portfolio-panel {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    border-radius: 18px !important;
    overflow-x: hidden !important;
  }

  .bitgak-chart-body .portfolio-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .bitgak-chart-body .portfolio-card,
  .bitgak-chart-body .portfolio-summary-card {
    min-width: 0 !important;
  }

  .bitgak-chart-body .portfolio-donut-wrap {
    grid-template-columns: 122px minmax(0, 1fr) !important;
    gap: 10px !important;
  }

  .bitgak-chart-body .portfolio-donut {
    width: 122px !important;
    height: 122px !important;
  }

  .bitgak-chart-body .portfolio-donut::after {
    inset: 24px !important;
  }

  .bitgak-chart-body .portfolio-donut span {
    inset: 34px !important;
    font-size: 12px !important;
  }

  .bitgak-chart-body .mobile-indicator-modal {
    align-items: flex-start !important;
    justify-content: center !important;
    padding: max(58px, env(safe-area-inset-top)) 10px 14px !important;
  }

  .bitgak-chart-body .mobile-indicator-panel {
    width: min(392px, calc(100vw - 20px)) !important;
    max-width: min(392px, calc(100vw - 20px)) !important;
    max-height: min(78vh, 620px) !important;
    max-height: min(78dvh, 620px) !important;
    border-radius: 24px !important;
  }

  .bitgak-chart-body .mobile-indicator-bottom-actions {
    padding-top: 12px !important;
  }

  .bitgak-chart-body #mobileAddIndicatorBtn {
    width: 100% !important;
    height: 46px !important;
    min-height: 46px !important;
    border-radius: 15px !important;
    font-size: 14px !important;
    font-weight: 1000 !important;
  }
}

@media (max-width: 420px) {
  .bitgak-chart-body .bv-header {
    grid-template-columns: 32px minmax(0, 1fr) 58px !important;
    padding-left: 9px !important;
    padding-right: 9px !important;
  }

  .bitgak-chart-body .bv-header-actions,
  .bitgak-chart-body .bv-header-actions a,
  .bitgak-chart-body .bv-header-actions button {
    width: 58px !important;
    min-width: 58px !important;
  }

  .bitgak-chart-body .bv-layout > .bv-main,
  .bitgak-chart-body .bv-layout-full > .bv-main,
  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
    padding-left: 9px !important;
    padding-right: 9px !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer {
    width: calc(100% - 18px) !important;
    max-width: calc(100% - 18px) !important;
  }

  .bitgak-chart-body .portfolio-donut-wrap {
    grid-template-columns: 108px minmax(0, 1fr) !important;
  }

  .bitgak-chart-body .portfolio-donut {
    width: 108px !important;
    height: 108px !important;
  }

  .bitgak-chart-body .portfolio-donut::after {
    inset: 22px !important;
  }

  .bitgak-chart-body .portfolio-donut span {
    inset: 30px !important;
    font-size: 11px !important;
  }
}

/* =========================================================
   Mobile tool modal hard fix v6
   - 모바일 평단가/포트폴리오 클릭 시 drawer를 차트 내부 absolute가 아니라
     viewport 기준 fixed modal로 강제 고정한다.
   - 기존 grid/padding/slide drawer 규칙을 모두 덮어써서 좌우 잘림을 방지한다.
   ========================================================= */
@media (max-width: 760px) {
  .bitgak-chart-body .bv-layout.bv-drawer-open,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    overflow: hidden !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-main,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-main {
    padding-left: 10px !important;
    padding-right: 10px !important;
    margin: 0 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open::before,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open::before {
    content: "" !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147482000 !important;
    display: block !important;
    background: rgba(2, 6, 23, 0.56) !important;
    backdrop-filter: blur(7px) !important;
    -webkit-backdrop-filter: blur(7px) !important;
    pointer-events: auto !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer,
  .bitgak-chart-body .bv-layout > .bv-left-panel.bv-tool-drawer,
  .bitgak-chart-body .bv-layout-full > .bv-left-panel.bv-tool-drawer {
    position: fixed !important;
    top: 118px !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    width: min(372px, calc(100vw - 28px)) !important;
    min-width: 0 !important;
    max-width: min(372px, calc(100vw - 28px)) !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: calc(100vh - 136px) !important;
    max-height: calc(100dvh - 136px) !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 24px !important;
    overflow: hidden !important;
    z-index: 2147483000 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    display: flex !important;
    flex-direction: column !important;
    transform: translate3d(-50%, 8px, 0) scale(0.985) !important;
    transform-origin: top center !important;
    transition: opacity .16s ease, transform .16s ease, visibility .16s ease !important;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.64) !important;
  }

  .bitgak-chart-body .bv-layout.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
  .bitgak-chart-body .bv-layout-full.bv-drawer-open > .bv-left-panel.bv-tool-drawer,
  .bitgak-chart-body .bv-left-panel.bv-tool-drawer.open {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    display: flex !important;
    transform: translate3d(-50%, 0, 0) scale(1) !important;
    grid-column: auto !important;
    grid-row: auto !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer.bv-drawer-closing {
    opacity: 0 !important;
    visibility: visible !important;
    pointer-events: none !important;
    display: flex !important;
    transform: translate3d(-50%, 8px, 0) scale(0.985) !important;
  }

  .bitgak-chart-body .bv-tool-drawer-head {
    flex: 0 0 auto !important;
    padding: 15px 16px 11px !important;
  }

  .bitgak-chart-body .bv-tool-drawer-head strong {
    font-size: 18px !important;
  }

  .bitgak-chart-body .bv-tool-drawer-tabs {
    flex: 0 0 auto !important;
    margin: 0 !important;
    padding: 11px 14px !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer .bv-drawer-view {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-height: calc(100vh - 250px) !important;
    max-height: calc(100dvh - 250px) !important;
    padding: 0 14px 14px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer .bv-drawer-view:not(.active) {
    display: none !important;
  }

  .bitgak-chart-body .bv-left-panel.bv-tool-drawer .bv-drawer-view.active {
    display: block !important;
  }

  .bitgak-chart-body .avg-calc-card,
  .bitgak-chart-body .portfolio-panel,
  .bitgak-chart-body .portfolio-card,
  .bitgak-chart-body .portfolio-summary-card {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .bitgak-chart-body .avg-calc-card {
    padding: 15px 13px !important;
  }

  .bitgak-chart-body .avg-calc-row {
    grid-template-columns: 38px minmax(92px, 1fr) 64px 82px 30px !important;
    gap: 6px !important;
  }

  .bitgak-chart-body .avg-calc-row input,
  .bitgak-chart-body .avg-calc-row select {
    height: 34px !important;
    font-size: 12px !important;
  }

  .bitgak-chart-body .avg-calc-row output {
    max-width: 82px !important;
    font-size: 11px !important;
  }

  .bitgak-chart-body .avg-row-actions {
    width: 30px !important;
    min-width: 30px !important;
  }

  .bitgak-chart-body .avg-row-style,
  .bitgak-chart-body .avg-row-delete {
    width: 24px !important;
    height: 26px !important;
  }

  .bitgak-chart-body .portfolio-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .bitgak-chart-body .portfolio-donut-wrap {
    grid-template-columns: 112px minmax(0, 1fr) !important;
    gap: 10px !important;
  }

  .bitgak-chart-body .portfolio-donut {
    width: 112px !important;
    height: 112px !important;
  }

  .bitgak-chart-body .portfolio-donut::after { inset: 22px !important; }
  .bitgak-chart-body .portfolio-donut span { inset: 30px !important; font-size: 11px !important; }
}

@media (max-width: 420px) {
  .bitgak-chart-body .bv-left-panel.bv-tool-drawer,
  .bitgak-chart-body .bv-layout > .bv-left-panel.bv-tool-drawer,
  .bitgak-chart-body .bv-layout-full > .bv-left-panel.bv-tool-drawer {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
  }

  .bitgak-chart-body .avg-calc-row {
    grid-template-columns: 36px minmax(84px, 1fr) 58px 76px 28px !important;
    gap: 5px !important;
  }

  .bitgak-chart-body .avg-calc-card {
    padding: 14px 12px !important;
  }
}
