/* ── Exchange layout tokens ──────────────────────────────── */
:root {
  --exchange-header-h: 56px;
  --panel-coin-w: 280px;
  --panel-order-w: 320px;
  --bottom-panel-h: 220px;
  --orderbook-w: 200px;
}

/* ── Exchange 3-panel layout ─────────────────────────────── */
body:has(.exchange-layout) main {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--exchange-header-h));
  overflow: hidden;
}

.exchange-layout {
  display: grid;
  grid-template-columns: var(--panel-coin-w) 1fr var(--panel-order-w);
  grid-template-rows: 1fr;
  flex: 1;
  min-height: 0;
  border-bottom: 1px solid var(--border);
}

/* ── Shared panel styles ─────────────────────────────────── */
.panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.panel:last-child { border-right: none; }

.panel-header {
  height: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Left: Coin list ─────────────────────────────────────── */
.panel-coin-list {
  background: var(--surface);
}

.panel-coin-list .panel-header {
  gap: 8px;
  flex-wrap: nowrap;
}

/* ── Market Breadth widget (Phase 2-B-3 PR 1-C) ────────── */
.market-breadth {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.market-breadth[data-state="loading"] { opacity: 0.55; }
.market-breadth[data-state="error"]   { opacity: 0.45; }

.mb-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.mb-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mb-counts {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.mb-counts .mb-up   { color: var(--up); font-weight: 600; }
.mb-counts .mb-down { color: var(--down); font-weight: 600; }
.mb-counts .mb-eq   { color: var(--text-muted); }

.mb-metrics {
  position: relative;  /* .mb-tip 의 위치 기준 — 사이드바 폭 전체 활용 */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.mb-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 4px;
  background: var(--bg, rgba(0, 0, 0, 0.04));
}
.mb-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.mb-value {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.mb-value.mb-positive { color: var(--up); }
.mb-value.mb-negative { color: var(--down); }
.mb-value.mb-neutral  { color: var(--text); }

/* 헬프 아이콘 */
.mb-help {
  width: 13px;
  height: 13px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
}
.mb-help:hover,
.mb-help:focus-visible {
  color: var(--text);
  border-color: var(--text-muted);
  outline: none;
}

/* 툴팁 본체 — hover/focus/터치 시 노출.
   사이드바(240px) 내부에 들어맞도록 폭 제한 — .panel의 overflow:hidden을
   유지하면서도 가로 클리핑 없이 노출시키는 트레이드오프. */
.mb-tip {
  position: absolute;
  top: calc(100% + 8px);
  left: 8px;
  right: 8px;
  /* 모바일 탭바(.exchange-mobile-tabs)는 z-index 50.
     호버 시점에 탭바 위로 떠야 가독성 보장. */
  z-index: 60;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  font-size: 11px;
  line-height: 1.45;
  color: var(--text);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 120ms, transform 120ms, visibility 120ms;
}
.mb-tip strong {
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--text);
}
.mb-tip-formula {
  display: block;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.mb-tip-scale {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mb-tip-scale li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mb-tip-tag {
  flex-shrink: 0;
  min-width: 56px;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(128, 128, 128, 0.12);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--text-muted);
}
/* 칩 색상 톤 제거 — 본문 텍스트와 색상 의미가 충돌해 혼란을 유발했음.
   매수/매도/중립 의미는 본문 라벨이 그대로 전달한다. */
.mb-tip-tag.mb-positive,
.mb-tip-tag.mb-negative { /* 기본 회색 톤 유지 */ }
.mb-tip-note {
  display: block;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
}

/* hover/focus 활성화 */
.mb-metric:hover .mb-tip,
.mb-metric:focus-within .mb-tip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.coin-search {
  flex: 1;
  height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}

.coin-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
}

/* ── Coin list column header ──────────────────────────────── */
.coin-list-header {
  display: grid;
  grid-template-columns: minmax(0,1fr) 58px 52px 58px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.col-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  padding: 5px 0;
  font-size: 10px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.1s;
}

.col-header.col-name {
  justify-content: flex-start;
}

.col-header:hover { color: var(--text); }

.col-header.active { color: var(--text); font-weight: 600; }

.col-sort-icon {
  font-size: 10px;
  width: 10px;
  text-align: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.col-header.active .col-sort-icon { color: var(--text); }

/* ── Coin rows ───────────────────────────────────────────── */
.coin-item-link {
  display: grid;
  grid-template-columns: minmax(0,1fr) 58px 52px 58px;
  align-items: center;
  gap: 0;
  padding: 6px 8px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.1s;
}

.coin-item-link:hover,
.coin-item.active .coin-item-link {
  background: var(--surface2);
  text-decoration: none;
}

.coin-item-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.coin-item-name-kr {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.coin-item-pair {
  font-size: 10px;
  color: var(--text-muted);
}

.coin-item-price {
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.coin-item-price.up   { color: var(--up); }
.coin-item-price.down { color: var(--down); }

.coin-item-change {
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.coin-item-change.up   { color: var(--up); }
.coin-item-change.down { color: var(--down); }

.coin-item-vol {
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Center: Chart + Orderbook ───────────────────────────── */
.panel-center {
  background: var(--chart-bg);
}

.center-header {
  justify-content: space-between;
  height: 52px;
  min-height: 52px;
  padding: 0 16px;
}

.coin-title {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.coin-title-symbol {
  font-size: 16px;
  font-weight: 700;
}

.coin-title-sep,
.coin-title-quote {
  font-size: 13px;
  color: var(--text-muted);
}

.coin-title-name {
  font-size: 12px;
  margin-left: 4px;
}

.ticker-summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.ticker-current-price {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ticker-change-rate {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.center-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr var(--orderbook-w);
  min-height: 0;
}

.chart-area {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

/* ── Triple Screen 분할 뷰 (Phase 2-B-4 PR 2) ────────────────
   토글 ON 시 .chart-area에 .chart-area--triple 클래스가 붙어
   기존 mainCanvas/subCanvas는 숨기고 #tripleScreen을 띄운다.
   .chart-area--triple 스코프가 이미 충분히 구체적이라 !important 불필요. */
.chart-area--triple #mainChart,
.chart-area--triple #subChartScroll,
.chart-area--triple .indicator-chips {
  display: none;
}
.triple-screen {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--border);
}
.triple-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
}
.triple-pane__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.triple-pane__title {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}
.triple-pane__meta {
  color: var(--text-muted);
  font-size: 10px;
}
.triple-pane__trend {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  background: rgba(128, 128, 128, 0.14);
  color: var(--text-muted);
}
.triple-pane__trend[data-trend="up"]   { color: var(--up);   background: rgba(239, 83, 80, 0.14); }
.triple-pane__trend[data-trend="down"] { color: var(--down); background: rgba(25, 118, 210, 0.14); }
.triple-pane__canvas {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: block;
}

/* 모바일: 분할 비활성 — 가장 중간 시간대(일봉)만 표시 */
@media (max-width: 768px) {
  .triple-screen { grid-template-columns: 1fr; }
  .triple-pane[data-pane="weekly"],
  .triple-pane[data-pane="h4"] { display: none; }
}

/* ── E-5: Ticker stats (고/저/거래량) ───────────────────────── */
.ticker-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: 16px;
}

.ticker-stat {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.ticker-stat-label {
  font-size: 10px;
  color: var(--text-muted);
}

.ticker-stat-value {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ── E-6: Chart toolbar ──────────────────────────────────────── */
.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

/* ── Interval dropdown selector ─────────────────────────────── */
.interval-selector {
  position: relative;
}

.interval-current-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  color: var(--text);
}

.interval-current-btn:hover {
  background: var(--surface3, var(--surface2));
}

.interval-arrow {
  font-size: 9px;
  color: var(--text-muted);
}

.interval-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  min-width: 110px;
  overflow: hidden;
}

.interval-dropdown.open {
  display: block;
}

.interval-group {
  padding: 6px 0 2px;
}

.interval-group + .interval-group {
  border-top: 1px solid var(--border);
}

.interval-group-label {
  padding: 2px 12px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.interval-option {
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.1s;
}

.interval-option:hover {
  background: var(--surface2);
}

.interval-option.active {
  background: var(--primary, #1976d2);
  color: #fff;
}

/* ── Chart type tabs ─────────────────────────────────────────── */
.chart-type-tabs {
  display: flex;
  gap: 2px;
  margin-left: auto;
  border-left: 1px solid var(--border);
  padding-left: 8px;
}

.chart-type-tab {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.1s, background 0.1s;
}

.chart-type-tab:hover {
  color: var(--text);
  background: var(--surface2);
}

.chart-type-tab.active {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface2);
}

/* ── E-6: Chart canvas ───────────────────────────────────────── */
.chart-canvas {
  display: block;
  width: 100%;
}

.sub-chart-canvas {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

/* ── E-7: Indicator bar ──────────────────────────────────────── */
.indicator-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  flex-wrap: wrap;
  row-gap: 2px;
}

.indicator-group {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
}

.indicator-overlay-group {
  border-right: 1px solid var(--border);
  padding-right: 6px;
  margin-right: 2px;
}

.ind-check,
.ind-radio {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 3px;
  transition: color 0.1s, background 0.1s;
  white-space: nowrap;
  user-select: none;
}

.ind-check:hover,
.ind-radio:hover {
  color: var(--text);
  background: var(--surface2);
}

.ind-check:has(input:checked),
.ind-radio:has(input:checked) {
  color: var(--text);
  background: var(--surface2);
  border-color: var(--border);
}

.ind-check input,
.ind-radio input {
  accent-color: var(--primary, #3b82f6);
  width: 11px;
  height: 11px;
}

/* ── E-6: OHLCV tooltip ─────────────────────────────────────── */
.chart-tooltip {
  position: absolute;
  top: 44px;
  left: 12px;
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 10;
  background: rgba(0,0,0,0.03);
  padding: 2px 6px;
  border-radius: 3px;
}

/* ── E-9: 중앙 패널 탭 (차트/호가창 전환) ──────────────────── */
.center-view-tabs {
  display: flex;
  gap: 0;
  height: 36px;
  min-height: 36px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.center-view-tab {
  padding: 0 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.center-view-tab:hover { color: var(--text); }
.center-view-tab.active { color: var(--text); border-bottom-color: var(--primary); }

/* 호가창 탭 활성 시: 차트 숨김, 호가창 전체 너비 */
.center-body.view-orderbook {
  grid-template-columns: 1fr;
}
.center-body.view-orderbook .chart-area {
  display: none;
}

/* ── E-8: 호가창 ─────────────────────────────────────────── */
.orderbook-area {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}

.orderbook {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 4px 0;
}

.orderbook-asks,
.orderbook-bids {
  display: flex;
  flex-direction: column;
}

.ob-row {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  padding: 3px 12px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.1s;
}

.ob-row:hover { background: rgba(255,255,255,0.04); }

/* 깊이(depth) 배경 바 */
.ob-depth {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 0;
  opacity: 0.18;
  transition: width 0.25s ease;
  pointer-events: none;
}

.ob-ask .ob-depth { background: var(--down); }
.ob-bid .ob-depth { background: var(--up); }

/* 매도 호가: --down (파란색), 매수 호가: --up (빨간색) */
.ob-ask .ob-price { color: var(--down); }
.ob-bid .ob-price { color: var(--up); }

.ob-price,
.ob-size {
  position: relative;
  z-index: 1;
}

.ob-size { color: var(--text-muted); }

.ob-spread {
  padding: 5px 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  background: var(--surface2);
  font-variant-numeric: tabular-nums;
}

/* ── Right: Order form ───────────────────────────────────── */
.panel-order {
  background: var(--surface);
}

.order-tabs {
  display: flex;
  gap: 2px;
  width: 100%;
}

.order-tab {
  flex: 1;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.order-tab:hover { background: var(--surface2); color: var(--text); }

.order-tab.active[data-tab="buy"]  { background: rgba(240, 68, 82, 0.15); color: var(--up); }
.order-tab.active[data-tab="sell"] { background: rgba(27, 100, 218, 0.15); color: var(--down); }

.order-login-notice {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.order-body {
  flex: 1;
  overflow-y: auto;
}

.order-tab-content {
  display: none;
  padding: 16px;
}

.order-tab-content.active { display: flex; flex-direction: column; gap: 14px; }

/* 주문유형 세그먼트 토글 (지정가/시장가) — 활성색은 매수=빨강/매도=파랑으로 side 와 일관 */
.order-type-toggle {
  display: flex;
  gap: 6px;
}
.order-type-btn {
  flex: 1;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.order-type-btn:hover { color: var(--text); border-color: var(--text-muted); }
.order-type-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
#orderTab-buy .order-type-btn.is-active {
  background: var(--up);
  border-color: var(--up);
}
#orderTab-sell .order-type-btn.is-active {
  background: var(--down);
  border-color: var(--down);
}

.order-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.order-total,
.order-balance {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.order-total-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── E-13~E-16: Order panel enhancements ─────────────────── */
.input-with-btn {
  display: flex;
  gap: 4px;
}

.input-with-btn .form-control {
  flex: 1;
  min-width: 0;
}

/* 브라우저 기본 number 스피너 제거 */
.form-control[type="number"]::-webkit-inner-spin-button,
.form-control[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.form-control[type="number"] {
  -moz-appearance: textfield;
}

.btn-current-price {
  flex-shrink: 0;
  align-self: stretch;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}

.btn-current-price:hover {
  background: var(--surface3, var(--surface2));
  color: var(--text);
}

.quick-btns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 6px;
}

.quick-btn {
  padding: 4px 0;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: background 0.1s, color 0.1s;
}

.quick-btn:hover {
  background: var(--surface3, var(--surface2));
  color: var(--text);
}

.order-fee {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.order-error {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--up);
  background: rgba(240, 68, 82, 0.1);
  border: 1px solid rgba(240, 68, 82, 0.3);
  border-radius: var(--radius-sm);
}

.btn-cancel-order {
  padding: 2px 8px;
  font-size: 11px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.btn-cancel-order:hover {
  background: rgba(240, 68, 82, 0.1);
  border-color: rgba(240, 68, 82, 0.4);
  color: var(--up);
}

/* ── Bottom panel ────────────────────────────────────────── */
.bottom-panel {
  height: var(--bottom-panel-h);
  min-height: var(--bottom-panel-h);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.bottom-tabs {
  display: flex;
  gap: 0;
  height: 40px;
  min-height: 40px;
  border-bottom: 1px solid var(--border);
}

.bottom-tab {
  padding: 0 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.bottom-tab:hover { color: var(--text); }
.bottom-tab.active { color: var(--text); border-bottom-color: var(--primary); }

.bottom-tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
}

.bottom-tab-content.active { display: block; }

/* ── Data table ──────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(42, 43, 48, 0.5);
  font-variant-numeric: tabular-nums;
}

.empty-row {
  text-align: center;
  color: var(--text-muted);
  padding: 24px 12px !important;
}

/* ── Quick-sell button ──────────────────────────────────── */
/* 빠른 매도 트리거 — 다이얼로그(매도=파란색)와 일관 */
.quick-sell-btn {
  white-space: nowrap;
  background: var(--primary);
  color: #fff;
  border: none;
}

/* ── Quick-sell dialog (다크 · 지표 모달과 일관 · 매도=파란색) ── */
.quick-sell-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: odFadeIn 0.15s ease-out;
}
.quick-sell-overlay[hidden] { display: none; }

.quick-sell-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  animation: odPopIn 0.22s ease-out;
  color: var(--text);
  padding: 22px 24px 24px;
}

.qs-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.qs-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  flex-shrink: 0;
}
.qs-head-text { flex: 1; min-width: 0; }
.qs-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}
.qs-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.qs-badge {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.qs-info {
  background: var(--surface2);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.qs-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}
.qs-info-row span { color: var(--text-muted); }
.qs-info-row strong {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.qs-pct {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.qs-pct-btn {
  flex: 1;
  padding: 9px 0;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
}
.qs-pct-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}
.qs-pct-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.qs-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  margin-bottom: 14px;
  transition: border-color 0.12s;
}
.qs-input:focus-within { border-color: var(--primary); }
/* 전역 input[type=number] 스타일(style.css)을 이기도록 .quick-sell-dialog 로 specificity ↑ */
.quick-sell-dialog .qs-input input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 12px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.quick-sell-dialog .qs-input input:hover,
.quick-sell-dialog .qs-input input:focus {
  background: transparent;
  border: none;
}
.qs-input-suffix {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.qs-preview {
  background: var(--surface2);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.qs-preview-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.qs-preview-row + .qs-preview-row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.qs-preview-row span {
  font-size: 12px;
  color: var(--text-muted);
}
.qs-preview-row strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.qs-preview-total strong {
  font-size: 17px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.3px;
}

.qs-error {
  font-size: 12px;
  color: var(--danger);
  margin-bottom: 12px;
}
.qs-error:empty { display: none; }

.qs-actions {
  display: flex;
  gap: 8px;
}
.qs-btn-ghost {
  flex: 1;
  padding: 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.qs-btn-ghost:hover { background: var(--surface2); color: var(--text); }
.qs-btn-primary {
  flex: 1.4;
  padding: 13px;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.qs-btn-primary:disabled { opacity: 0.6; cursor: default; }

/* ── Toast notification ─────────────────────────────────── */
.exchange-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 10px 16px;
  z-index: 1100;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.exchange-toast--visible { opacity: 1; transform: translateY(0); }
.exchange-toast--error { border-color: var(--danger); color: var(--danger); }

/* ── Scrollbar styling ───────────────────────────────────── */
.coin-list::-webkit-scrollbar,
.orderbook::-webkit-scrollbar,
.order-body::-webkit-scrollbar,
.bottom-tab-content::-webkit-scrollbar,
.ind-lib-list::-webkit-scrollbar,
.ind-applied-list::-webkit-scrollbar {
  width: 4px;
}

.coin-list::-webkit-scrollbar-track,
.orderbook::-webkit-scrollbar-track,
.order-body::-webkit-scrollbar-track,
.bottom-tab-content::-webkit-scrollbar-track,
.ind-lib-list::-webkit-scrollbar-track,
.ind-applied-list::-webkit-scrollbar-track {
  background: transparent;
}

.coin-list::-webkit-scrollbar-thumb,
.orderbook::-webkit-scrollbar-thumb,
.order-body::-webkit-scrollbar-thumb,
.bottom-tab-content::-webkit-scrollbar-thumb,
.ind-lib-list::-webkit-scrollbar-thumb,
.ind-applied-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* Firefox 호환 — 같은 영역에 얇은 스크롤바 톤 일관 */
.coin-list,
.orderbook,
.order-body,
.bottom-tab-content,
.ind-lib-list,
.ind-applied-list {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ── Mobile tab bar (모바일에서만 노출) ────────────────── */
.exchange-mobile-tabs {
  display: none;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
  scrollbar-width: none;
}
.exchange-mobile-tabs::-webkit-scrollbar { display: none; }

.exchange-mobile-tab {
  flex-shrink: 0;
  height: 40px;
  padding: 0 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.exchange-mobile-tab.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1100px) {
  .exchange-layout {
    grid-template-columns: var(--panel-coin-w) 1fr;
  }
  .panel-right-col { display: none; }
}

@media (max-width: 768px) {
  /* main: 헤더만큼 빼고 화면 안에서 끝나도록 유지 (data-mobile-view 안 보이는 패널의 0폭/0높이 방지) */
  body:has(.exchange-layout) main {
    height: calc(100vh - var(--exchange-header-h));
    overflow: hidden;
  }
  .exchange-mobile-tabs { display: flex; }

  .exchange-layout {
    grid-template-columns: 1fr;
    /* flex: 1, min-height: 0 은 데스크탑 정의를 그대로 사용 — 차트 높이 보장 */
  }

  /* 내역 탭: 하단 패널이 남은 공간을 차지하도록 (너무 길어지지 않게) */
  body[data-exch-view="history"] .bottom-panel {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  /* Mobile: show only the active panel */
  .exchange-layout[data-mobile-view="coins"]  .panel-coin-list { display: flex; }
  .exchange-layout[data-mobile-view="coins"]  .panel-center,
  .exchange-layout[data-mobile-view="coins"]  .panel-right-col { display: none; }

  .exchange-layout[data-mobile-view="chart"]  .panel-center      { display: flex; }
  .exchange-layout[data-mobile-view="chart"]  .panel-center .chart-area     { display: flex; }
  .exchange-layout[data-mobile-view="chart"]  .panel-center .orderbook-area { display: none; }
  .exchange-layout[data-mobile-view="chart"]  .panel-center .center-body    { grid-template-columns: 1fr; }
  .exchange-layout[data-mobile-view="chart"]  .panel-coin-list,
  .exchange-layout[data-mobile-view="chart"]  .panel-right-col { display: none; }

  /* 호가 탭: panel-center 안에서 차트만 숨기고 호가창 전체 너비로 노출 */
  .exchange-layout[data-mobile-view="orderbook"] .panel-center                  { display: flex; }
  .exchange-layout[data-mobile-view="orderbook"] .panel-center .chart-area      { display: none; }
  .exchange-layout[data-mobile-view="orderbook"] .panel-center .orderbook-area  { display: flex; }
  .exchange-layout[data-mobile-view="orderbook"] .panel-center .center-body     { grid-template-columns: 1fr; }
  .exchange-layout[data-mobile-view="orderbook"] .panel-center .center-view-tabs { display: none; }
  .exchange-layout[data-mobile-view="orderbook"] .panel-coin-list,
  .exchange-layout[data-mobile-view="orderbook"] .panel-right-col { display: none; }

  .exchange-layout[data-mobile-view="order"]  .panel-right-col {
    display: flex; flex-direction: column;
    width: 100%; min-width: 0;
  }
  .exchange-layout[data-mobile-view="order"]  .panel-coin-list,
  .exchange-layout[data-mobile-view="order"]  .panel-center    { display: none; }

  /* "내역" 탭: 3패널 영역 숨김 / 코인목록·차트·호가·주문 탭: 하단 패널 숨김 */
  body[data-exch-view="history"]   .exchange-layout { display: none; }
  body[data-exch-view="coins"]     .bottom-panel,
  body[data-exch-view="chart"]     .bottom-panel,
  body[data-exch-view="orderbook"] .bottom-panel,
  body[data-exch-view="order"]     .bottom-panel { display: none; }

  .panel-coin-list { width: 100%; }
  .panel-coin-list .panel-header { flex-wrap: nowrap; }

  .center-body { grid-template-columns: 1fr; }
  /* 모바일에선 panel-center 자체 호가/차트 토글탭은 노출 안 함 — 외부 탭 바에서 이미 전환 */
  .panel-center .center-view-tabs { display: none; }

  .bottom-panel {
    height: auto;
    min-height: var(--bottom-panel-h);
  }

  /* 차트 패널 헤더(코인명 + 시세) — 가로 공간 부족 시 깨지지 않도록 */
  .center-header {
    height: 52px;
    min-height: 52px;
    padding: 0 12px;
    gap: 8px;
  }
  .coin-title { flex-shrink: 0; min-width: 0; gap: 2px; }
  .coin-title-symbol { font-size: 14px; }
  .coin-title-sep,
  .coin-title-quote,
  .coin-title-name { display: none; } /* 좁은 모바일에선 /KRW · 코인 한글명 숨김 */

  .ticker-summary {
    flex: 1 1 0;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .ticker-summary::-webkit-scrollbar { display: none; }
  .ticker-current-price { font-size: 16px; flex-shrink: 0; }
  .ticker-change-rate   { font-size: 12px; flex-shrink: 0; }
  .ticker-stats { gap: 10px; margin-left: 10px; flex-shrink: 0; }
  .ticker-stat-label,
  .ticker-stat-value { white-space: nowrap; }

  /* 차트 툴바: overflow 를 두면 interval-dropdown 이 잘리므로 wrap 으로 대체 */
  .chart-toolbar { flex-wrap: wrap; row-gap: 4px; }
  .indicator-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .indicator-group { flex-shrink: 0; }
  .ind-check, .ind-radio { flex-shrink: 0; padding: 2px 4px; font-size: 10px; }

  /* 하단 테이블 가로 스크롤 */
  .bottom-tab-content { overflow-x: auto; }
  .data-table { min-width: 640px; }
}

/* ═══════════════════════════════════════════════════════════════
   Indicator Modal — design-mockup-aligned customization UI
   ═══════════════════════════════════════════════════════════════ */

/* ── Trigger button (chart-toolbar) ────────────────────────────── */
.indicator-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  margin-left: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.indicator-trigger-btn:hover {
  background: var(--border);
  border-color: #4a4b53;
}
/* Phase 2-B-3 PR 1-D: 피보나치 도구 토글 활성 상태 */
.indicator-trigger-btn.active {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.55);
  color: rgb(245, 158, 11);
}
/* 작은 × 클리어 버튼 — 같은 높이, 정사각 */
.indicator-trigger-btn.fib-clear-btn {
  padding: 0;
  width: 24px;
  font-size: 16px;
  line-height: 1;
  justify-content: center;
}
.indicator-trigger-btn .ind-trigger-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

/* ── Tool help (Phase 2-B-4) ──────────────────────────────────
   토글 버튼 옆에 작은 ? 아이콘 + 호버 시 도움말 툴팁.
   기준 위치는 .tool-with-help, 툴팁은 행 아래로 펼침. */
.tool-with-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.tool-help {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.tool-help:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--text-muted);
}

.tool-help-tip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  width: 280px;
  max-width: calc(100vw - 24px);
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text);
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 130ms, transform 130ms, visibility 130ms;
}
/* 아이콘과 툴팁 사이 8px 갭을 hover로 잇는 투명 브릿지 */
.tool-help-tip::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 8px;
}
.tool-with-help:has(.tool-help:hover) .tool-help-tip,
.tool-help-tip:hover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
/* :has() 미지원 브라우저 폴백 (Firefox < 121 등) — .tool-with-help
   전체 hover로 트리거. 토글 버튼 hover 시에도 툴팁이 떠 약간 손해지만
   접근성은 보장. */
@supports not selector(:has(*)) {
  .tool-with-help:hover .tool-help-tip {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }
}

.tool-help-tip strong {
  display: block;
  font-size: 12.5px;
  margin-bottom: 6px;
  color: var(--text);
}
.tool-tip-desc {
  display: block;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
}
.tool-tip-scale {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tool-tip-scale li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}
.tool-tip-mk {
  flex-shrink: 0;
  min-width: 64px;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(128, 128, 128, 0.14);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  color: var(--text-muted);
}
.tool-tip-mk.tool-tip-bull    { color: var(--up); }
.tool-tip-mk.tool-tip-bear    { color: var(--down); }
.tool-tip-mk.tool-tip-neutral { color: var(--text-muted); }
.tool-tip-note {
  display: block;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
}

/* ── Active indicator chips above chart ────────────────────────── */
.indicator-chips {
  display: flex;
  gap: 6px;
  padding: 5px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.indicator-chips::-webkit-scrollbar { display: none; }
.ind-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 5px;
  background: var(--surface2);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.ind-chip-dot {
  display: inline-block;
  width: 8px;
  height: 2px;
  border-radius: 1px;
}

/* ── Modal backdrop ────────────────────────────────────────────── */
.indicator-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: indModalFade 0.15s ease-out;
}
.indicator-modal.open { display: flex; }
@keyframes indModalFade { from { opacity: 0 } to { opacity: 1 } }
@keyframes indModalPop  { from { opacity: 0; transform: translateY(8px) scale(0.98) } to { opacity: 1; transform: none } }

.ind-modal-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 780px;
  height: min(640px, 92vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  animation: indModalPop 0.18s ease-out;
}

/* ── Modal header ──────────────────────────────────────────────── */
.ind-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.ind-modal-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.ind-modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 2px;
}
.ind-modal-close {
  margin-left: auto;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: none; border-radius: 6px;
  cursor: pointer;
}
.ind-modal-close:hover { background: var(--surface2); color: var(--text); }

/* ── Modal body 2-column ───────────────────────────────────────── */
.ind-modal-body {
  flex: 1;
  display: flex;
  min-height: 0;
}
.ind-left {
  width: 300px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.ind-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

/* ── Search + categories ───────────────────────────────────────── */
.ind-left-top {
  padding: 14px 14px 10px;
}
.ind-search-wrap {
  position: relative;
  margin-bottom: 10px;
}
.ind-search-wrap svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.ind-search-wrap input {
  width: 100%;
  padding: 8px 12px 8px 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.ind-search-wrap input::placeholder { color: var(--text-muted); }
.ind-search-wrap input:focus { border-color: var(--primary); }

.ind-cat-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.ind-cat-chip {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 14px;
  border: none;
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.ind-cat-chip:hover { color: var(--text); }
.ind-cat-chip.active {
  background: var(--text);
  color: var(--bg);
}

/* ── Library list ──────────────────────────────────────────────── */
.ind-lib-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ind-lib-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  text-align: left;
  width: 100%;
}
.ind-lib-row:hover { background: var(--surface2); }
.ind-lib-row.active {
  background: rgba(27, 100, 218, 0.12);
  border-color: rgba(27, 100, 218, 0.35);
}
.ind-lib-thumb {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: -0.3px;
  flex-shrink: 0;
}
.ind-lib-thumb.active { background: var(--primary); color: #fff; }
.ind-lib-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.ind-lib-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.ind-lib-desc {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ind-lib-cta {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ind-lib-cta.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.ind-empty {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Indicator help tooltip (Phase 2-B-3) ───────────────────────
   ? 아이콘 hover (또는 행 키보드 포커스) 시 행 바로 아래로 펼침.
   행 우측으로 펼치면 부모 .ind-lib-list { overflow-y: auto }의 클리핑
   컨텍스트에 잘리므로, 목록 박스 안 세로 방향으로 펼친다. */
.ind-lib-row { position: relative; }

/* ? 헬프 아이콘 — 행 우측, CTA 좌측에 위치 */
.ind-lib-help {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.ind-lib-help:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--surface2);
}

.ind-lib-tip {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text);
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 130ms, transform 130ms, visibility 130ms;
}
/* ?와 툴팁 사이 4px 간격을 마우스가 지날 때 hover 트리거가 끊기지
   않도록 위쪽 투명 브릿지 영역을 둠. 시각상 카드는 그대로 4px 떨어짐. */
.ind-lib-tip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 0;
  right: 0;
  height: 6px;
}
/* 마우스: ? 아이콘 hover 또는 툴팁 위로 마우스 이동 유지.
   :has() 사용 — 형제 결합자(~)는 .ind-lib-help이 .ind-lib-tip보다 앞에
   와야만 동작해 향후 DOM 순서 바뀌면 조용히 깨짐. :has()로 행 부모
   기준 매칭하면 순서 비의존.  키보드: 행 포커스. */
.ind-lib-row:has(.ind-lib-help:hover) .ind-lib-tip,
.ind-lib-tip:hover,
.ind-lib-row:focus-visible .ind-lib-tip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
.ind-lib-tip strong {
  display: block;
  font-size: 12.5px;
  margin-bottom: 6px;
  color: var(--text);
}
.ind-tip-formula {
  display: block;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
.ind-tip-scale {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ind-tip-scale li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.ind-tip-tag {
  flex-shrink: 0;
  min-width: 64px;
  max-width: 130px;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(128, 128, 128, 0.14);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 칩 색상 톤 제거 — 본문 텍스트와 색상 의미가 충돌해 혼란을 유발했음.
   매수/매도/중립 의미는 본문 라벨이 그대로 전달한다. */
.ind-tip-tag.ind-tip-pos,
.ind-tip-tag.ind-tip-neg { /* 기본 회색 톤 유지 */ }
.ind-tip-text {
  flex: 1;
  color: var(--text);
  font-size: 11px;
}


/* ── Applied list ──────────────────────────────────────────────── */
.ind-right-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 16px 8px;
}
.ind-right-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.ind-right-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: rgba(27, 100, 218, 0.18);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.ind-clear-all {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.ind-clear-all:hover { color: var(--text); }

.ind-applied-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ind-applied-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.7;
  padding: 40px 0;
}

.ind-applied-row {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.12s;
}
.ind-applied-row.expanded { border-color: var(--primary); }
.ind-applied-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
}
.ind-applied-swatch {
  flex-shrink: 0;
  width: 26px; height: 10px;
  position: relative;
}
.ind-applied-swatch::before {
  content: '';
  position: absolute; inset: 0;
  margin: auto 0;
  height: var(--w, 2px);
  background: var(--c, #9ca3af);
  border-radius: 1px;
}
.ind-applied-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ind-applied-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.ind-applied-name.faded { color: var(--text-muted); }
.ind-applied-meta {
  font-size: 11px;
  color: var(--text-muted);
}
.ind-applied-pane {
  font-size: 9px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.6;
}
.ind-applied-pane.overlay {
  background: rgba(27, 100, 218, 0.18);
  color: var(--primary);
}
.ind-applied-pane.sub {
  background: var(--surface2);
  color: var(--text-muted);
}
.ind-applied-btn {
  width: 26px; height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
.ind-applied-btn:hover { background: var(--surface2); color: var(--text); }
.ind-applied-btn.active {
  background: rgba(27, 100, 218, 0.18);
  color: var(--primary);
}
.ind-remove-btn { color: var(--text-muted); }

/* ── Param editor (expanded) ───────────────────────────────────── */
.ind-param-editor {
  padding: 12px 14px 14px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.ind-param-section { margin-bottom: 10px; }
.ind-param-section:last-child { margin-bottom: 0; }
.ind-param-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 6px;
}
.ind-param-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.ind-param-flex {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.ind-color-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
  cursor: pointer;
  padding: 0;
  transition: box-shadow 0.12s;
}
.ind-color-btn.active {
  box-shadow: 0 0 0 2px var(--text);
}

.ind-style-group,
.ind-width-group {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
}
.ind-style-btn,
.ind-width-btn {
  padding: 4px 8px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.ind-style-btn.active,
.ind-width-btn.active {
  background: var(--surface2);
  color: var(--text);
}
.ind-width-btn { width: 32px; padding: 6px 0; justify-content: center; }
.ind-width-bar {
  display: inline-block;
  width: 18px;
  border-radius: 2px;
}

/* ── Mobile (≤ 768px) ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .indicator-modal { padding: 10px; }
  .ind-modal-panel {
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .ind-modal-body { flex-direction: column; }
  .ind-left {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 45%;
  }
  .indicator-trigger-btn { padding: 4px 8px; font-size: 11px; }
  .indicator-trigger-btn span:not(.ind-trigger-badge) { display: none; }
}

/* ── Multi-period support (SMA/EMA) ───────────────────────────── */
.ind-applied-swatch.multi {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  width: auto;
  height: auto;
  padding: 2px;
}
.ind-multi-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.ind-period-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.ind-period-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.ind-period-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ind-period-val {
  font-variant-numeric: tabular-nums;
}
.ind-period-chip-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  border-radius: 4px;
}
.ind-period-chip-remove:hover {
  color: var(--text);
  background: var(--surface2);
}

.ind-period-add {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.ind-period-add-input {
  width: 56px;
  padding: 4px 8px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.ind-period-add-input::placeholder { color: var(--text-muted); }
.ind-period-add-input::-webkit-outer-spin-button,
.ind-period-add-input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.ind-period-add-btn {
  padding: 4px 9px;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.ind-period-add-btn:hover { color: var(--text); background: var(--surface2); }

/* ── Multi-period chip editing ────────────────────────────────── */
.ind-period-chip {
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.ind-period-chip:hover {
  background: var(--surface2);
}
.ind-period-chip.editing {
  background: var(--surface2);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(27, 100, 218, 0.18);
}

.ind-period-edit {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--primary);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: indEditFade 0.14s ease-out;
}
@keyframes indEditFade { from { opacity: 0; transform: translateY(-3px) } to { opacity: 1; transform: none } }

.ind-period-edit-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ind-period-edit-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  flex-shrink: 0;
  min-width: 36px;
}
.ind-period-edit-input {
  width: 56px;
  padding: 5px 0;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ind-period-edit-input::-webkit-outer-spin-button,
.ind-period-edit-input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.ind-period-edit-btn {
  padding: 5px 9px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.ind-period-edit-btn:hover { color: var(--text); }
.ind-period-edit .ind-num-box {
  display: inline-flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.ind-period-color-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
  cursor: pointer;
  padding: 0;
  transition: box-shadow 0.12s;
}
.ind-period-color-btn.active {
  box-shadow: 0 0 0 2px var(--text);
}

/* ── Param grid (RSI/MACD/Stoch — design mockup) ──────────────── */
.ind-num-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}
.ind-num-cell-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 5px;
}
.ind-num-cell-box {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}
.ind-num-cell-btn {
  padding: 7px 9px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}
.ind-num-cell-btn:hover {
  color: var(--text);
  background: var(--surface2);
}
.ind-num-cell-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  text-align: center;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  padding: 7px 0;
  font-variant-numeric: tabular-nums;
}
.ind-num-cell-input::-webkit-outer-spin-button,
.ind-num-cell-input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}

/* 칩이 표시될 때 chart-tooltip(OHLC)을 칩 아래로 이동 — 호버 가독성 확보 */
.chart-area.has-chips .chart-tooltip {
  top: 76px;
}

/* ── Sub chart scrollable container ───────────────────────────── */
.sub-chart-scroll {
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  /* height/max-height/overflow-y는 chart.js의 _resize가 인라인으로 설정.
     border-top은 두지 않음 — 컨테이너 content area를 1px 줄여 canvas가 잘리는 문제 방지 */
}
.sub-chart-scroll::-webkit-scrollbar {
  width: 6px;
}
.sub-chart-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.sub-chart-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.sub-chart-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
.sub-chart-scroll .sub-chart-canvas {
  display: block;
  border-top: none;
}

/* ── 매도 완료 모달 (modal.html Variation A · 매도=파란색) ───────────── */
@keyframes odFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes odPopIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes odCheckDraw {
  0% { stroke-dashoffset: 60; opacity: 0; }
  30% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}
@keyframes odRingPulse {
  0% { transform: scale(0.6); opacity: 0; }
  50% { opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

.order-done-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: odFadeIn 0.15s ease-out;
}
.order-done-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  animation: odPopIn 0.22s ease-out;
  overflow: hidden;
  color: var(--text);
}
.order-done-header {
  padding: 32px 28px 20px;
  text-align: center;
  background: linear-gradient(180deg, rgba(27, 100, 218, 0.12) 0%, transparent 100%);
}
.order-done-check {
  position: relative;
  display: inline-flex;
  margin-bottom: 14px;
}
.order-done-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.18;
  animation: odRingPulse 1.4s ease-out infinite;
}
.order-done-check-path { animation: odCheckDraw 0.6s ease-out forwards; }
.order-done-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}
.order-done-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}
.order-done-coinrow {
  padding: 0 28px 18px;
  display: flex;
  align-items: center;
}
.order-done-pill {
  display: flex;
  align-items: center;
  gap: 8px;
}
.order-done-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
}
.order-done-coinid {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.order-done-coinname {
  font-size: 10px;
  color: var(--text-muted);
}
.order-done-badge {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.order-done-total {
  margin: 0 28px 18px;
  padding: 16px 18px;
  background: var(--surface2);
  border-radius: 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.order-done-total-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}
.order-done-total-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}
.order-done-details { padding: 0 28px 22px; }
.order-done-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
}
.order-done-row span:first-child {
  font-size: 12px;
  color: var(--text-muted);
}
.order-done-row span:last-child {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.order-done-mono { font-family: inherit; }
.order-done-ctas {
  display: flex;
  gap: 8px;
  padding: 0 28px 24px;
}
.order-done-btn-ghost {
  flex: 1;
  padding: 13px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
}
.order-done-btn-ghost:hover { background: var(--surface2); color: var(--text); }
.order-done-btn-primary {
  flex: 1.4;
  padding: 13px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
}
/* 매수 = 빨강 액센트 (체크마크 색은 JS 인라인 SVG 에서 처리) */
.order-done-card.is-buy .order-done-ring,
.order-done-card.is-buy .order-done-logo,
.order-done-card.is-buy .order-done-badge,
.order-done-card.is-buy .order-done-btn-primary {
  background: var(--danger);
}
.order-done-card.is-buy .order-done-header {
  background: linear-gradient(180deg, rgba(240, 68, 82, 0.12) 0%, transparent 100%);
}
@media (prefers-reduced-motion: reduce) {
  .order-done-overlay,
  .order-done-card,
  .order-done-ring,
  .order-done-check-path {
    animation: none;
  }
}
