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

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0f1117;
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: #1a1d27;
  border-bottom: 1px solid #2a2d3a;
  padding: 16px 24px;
  flex-shrink: 0;
}

header h1 {
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.5px;
}

header h1 span {
  color: #f7a600;
}

/* ── 컨트롤바 ──────────────────────────────────────────────────────────── */
.controls {
  background: #1a1d27;
  border-bottom: 1px solid #2a2d3a;
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  flex-shrink: 0;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-group label {
  font-size: 11px;
  color: #888;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

select, input[type="date"] {
  background: #0f1117;
  border: 1px solid #2a2d3a;
  color: #e0e0e0;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  min-width: 120px;
}

select:focus, input[type="date"]:focus {
  border-color: #f7a600;
}

select option {
  background: #1a1d27;
}

.btn-group {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

button {
  padding: 7px 18px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

button:active {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#btn-fetch {
  background: #f7a600;
  color: #000;
}

#btn-fetch:hover:not(:disabled) {
  opacity: 0.85;
}

#btn-chart {
  background: #2563eb;
  color: #fff;
}

#btn-chart:hover:not(:disabled) {
  opacity: 0.85;
}

/* ── 인디케이터 바 ──────────────────────────────────────────────────────── */
.indicator-bar {
  background: #1a1d27;
  border-bottom: 1px solid #2a2d3a;
  padding: 8px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
  min-height: 44px;
}

.indicator-add {
  display: flex;
  align-items: center;
  gap: 8px;
}

.indicator-add label {
  font-size: 11px;
  color: #888;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.indicator-add select {
  min-width: 180px;
  padding: 5px 8px;
  font-size: 12px;
}

#btn-add-indicator {
  background: #2a2d3a;
  color: #e0e0e0;
  border: 1px solid #3a3d4a;
  padding: 5px 12px;
  font-size: 12px;
}

#btn-add-indicator:hover {
  background: #3a3d4a;
}

#indicator-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.indicator-tag {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #252836;
  border: 1px solid #3a3d4a;
  border-radius: 4px;
  padding: 3px 6px 3px 8px;
  font-size: 12px;
  color: #d0d0d0;
}

.indicator-tag .tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.indicator-tag button {
  background: none;
  border: none;
  color: #666;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transform: none;
}

.indicator-tag button:hover {
  color: #ef4444;
}

/* ── 차트 시간대 표시 ────────────────────────────────────────────────── */
#chart-timerange {
  text-align: center;
  font-size: 12px;
  color: #888;
  padding: 2px 0;
  background: #0f0f0f;
}

/* ── 상태 바 ─────────────────────────────────────────────────────────── */
.status-bar {
  padding: 8px 24px;
  background: #13151f;
  border-bottom: 1px solid #2a2d3a;
  font-size: 13px;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.status-bar.error   { color: #ef4444; }
.status-bar.success { color: #22c55e; }
.status-bar.loading { color: #f7a600; }

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid #333;
  border-top-color: #f7a600;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── 차트 영역 ──────────────────────────────────────────────────────────── */
#chart-area {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  overflow: hidden;
}

/* ── 드로잉 툴바 ────────────────────────────────────────────────────────── */
#drawing-toolbar {
  width: 44px;
  flex-shrink: 0;
  background: #1a1d27;
  border-right: 1px solid #2a2d3a;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
}

.tool-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #888;
  padding: 0;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.tool-btn:hover {
  background: #252836;
  color: #e0e0e0;
  border-color: #3a3d4a;
  transform: none;
}

.tool-btn.active {
  background: #1e3a5f;
  color: #60a5fa;
  border-color: #2563eb;
}

.toolbar-sep {
  width: 24px;
  height: 1px;
  background: #2a2d3a;
  margin: 2px 0;
}

/* ── 차트 열 (패널들) ────────────────────────────────────────────────────── */
#charts-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* 메인 차트 래퍼 */
#main-chart-wrapper {
  flex: 1;
  min-height: 300px;
  position: relative;
  overflow: hidden;
}

#chart-container {
  position: absolute;
  inset: 0;
}

#chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #444;
  gap: 12px;
  z-index: 1;
}

#chart-empty svg {
  opacity: 0.4;
}

#chart-empty p {
  font-size: 14px;
}

/* 드로잉 캔버스 — 차트 위에 절대 위치 */
#drawing-canvas {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

/* ── 보조 패널 (RSI, MACD) ──────────────────────────────────────────────── */
.sub-panel {
  display: none;
  flex-direction: column;
  height: 160px;
  flex-shrink: 0;
  border-top: 1px solid #2a2d3a;
  background: #0f1117;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  height: 26px;
  background: #13151f;
  border-bottom: 1px solid #1f2937;
  font-size: 11px;
  color: #888;
  flex-shrink: 0;
}

.btn-close-panel {
  background: none;
  border: none;
  color: #666;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  transform: none;
}

.btn-close-panel:hover {
  color: #ef4444;
}

#rsi-chart,
#macd-chart {
  flex: 1;
  min-height: 0;
}
