/* 코인 차트 · 트레이딩뷰 다크 팔레트 */
:root {
  --bg: #131722;
  --bg2: #1e222d;
  --line: #2a2e39;
  --text: #d1d4dc;
  --muted: #787b86;
  --accent: #2962ff;
  --up: #26a69a;
  --down: #ef5350;
  --warn: #ff9800;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible { outline: 1px solid var(--accent); }
.up { color: var(--up); }
.down { color: var(--down); }

/* ── 상단 툴바 ── */
#top {
  display: flex; align-items: center; gap: 4px;
  height: 40px; padding: 0 8px; background: var(--bg2); border-bottom: 1px solid var(--line);
  flex-shrink: 0; overflow-x: auto; overflow-y: visible; white-space: nowrap;
}
#top::-webkit-scrollbar { display: none; }
.brand { font-weight: 700; padding: 0 8px 0 2px; color: var(--muted); letter-spacing: .02em; }
.group { display: flex; align-items: center; gap: 2px; position: relative; }
.group + .group::before { content: ""; width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.spacer { flex: 1; }
.tb, .iv, .sym {
  height: 28px; padding: 0 9px; border-radius: 4px; color: var(--text); white-space: nowrap;
}
.tb:hover, .iv:hover, .sym:hover { background: rgba(255,255,255,.06); }
.tb.on, .iv.on, .sym.on { background: rgba(41,98,255,.18); color: #fff; }
.iv { padding: 0 8px; color: var(--muted); font-weight: 500; }
.iv.on { color: #fff; }
.sym { display: flex; align-items: center; gap: 8px; padding: 0 10px; }
.sym-name { font-weight: 700; }
.sym-krw { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sym-krw em { font-style: normal; font-size: 11px; margin-left: 2px; }
.sym.on .sym-krw { color: #b2b5be; }
.sym-x { color: var(--muted); margin-left: 2px; padding: 0 2px; border-radius: 3px; }
.sym-x:hover { background: rgba(239,83,80,.25); color: #fff; }
.sym-add { color: var(--muted); padding: 0 8px; font-size: 16px; }
.sym-input {
  height: 28px; width: 100px; padding: 0 8px; border-radius: 4px; border: 1px solid var(--accent);
  background: var(--bg); color: #fff; font: inherit; text-transform: uppercase; outline: 0;
}
.badge { font-size: 11px; color: var(--accent); font-weight: 700; margin-left: 2px; }

/* ── 드롭다운 ── */
.menu {
  position: absolute; top: 34px; left: 0; z-index: 30; min-width: 220px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45); white-space: normal;
}
.menu-wide { min-width: 320px; right: 0; left: auto; }
.ind-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: 4px; cursor: pointer; }
.ind-row:hover { background: rgba(255,255,255,.05); }
.ind-row span { flex: 1; }
.ind-row input[type=checkbox] { accent-color: var(--accent); margin: 0; }
.ind-periods {
  width: 90px; height: 24px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-size: 12px; outline: 0;
}
.ind-periods:focus { border-color: var(--accent); }
#alert-list { max-height: 320px; overflow: auto; }
.empty { color: var(--muted); padding: 10px 8px; font-size: 12px; line-height: 1.5; }
.alert-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.alert-row:hover { background: rgba(255,255,255,.05); }
.alert-row.done { color: var(--muted); }
.a-sym { font-weight: 700; width: 44px; }
.a-price { flex: 1; }
.a-st { font-size: 11px; color: var(--muted); white-space: nowrap; }
.a-x { color: var(--muted); padding: 0 4px; border-radius: 3px; }
.a-x:hover { background: rgba(239,83,80,.25); color: #fff; }

/* ── 본문 ── */
#body { flex: 1; display: flex; min-height: 0; }
#rail {
  width: 40px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; padding-top: 6px; gap: 2px;
}
#rail button { width: 32px; height: 32px; border-radius: 4px; color: var(--muted); display: grid; place-items: center; }
#rail button:hover { background: rgba(255,255,255,.06); color: var(--text); }
#rail button.on { background: rgba(41,98,255,.18); color: #fff; }
#rail svg { width: 18px; height: 18px; }
.rail-gap { height: 8px; }

#panels { flex: 1; display: grid; gap: 1px; background: var(--line); min-width: 0; }
#panels[data-layout="2h"] { grid-template-columns: 1fr 1fr; }
#panels[data-layout="2v"] { grid-template-rows: 1fr 1fr; }
.lay { padding: 0 6px; display: grid; place-items: center; }
.lay svg { width: 18px; height: 18px; }
.panel { position: relative; background: var(--bg); min-width: 0; min-height: 0; outline: 1px solid transparent; outline-offset: -1px; }
.panel.active { outline-color: rgba(41,98,255,.55); }
#panels[data-layout="1"] .panel.active { outline-color: transparent; }
.panel .chart { position: absolute; inset: 0; }
.panel .chart.drawing { cursor: crosshair; }
.panel .chart.alerting { cursor: cell; }
.panel.offline::after {
  content: "재접속 중"; position: absolute; top: 6px; right: 70px; z-index: 6;
  font-size: 11px; color: var(--warn); background: rgba(19,23,34,.85); padding: 2px 6px; border-radius: 3px;
}

/* ── 범례 (좌상단) ── */
.legend {
  position: absolute; top: 6px; left: 8px; z-index: 5; pointer-events: none;
  font-size: 12px; font-variant-numeric: tabular-nums; line-height: 1.5;
  text-shadow: 0 0 3px var(--bg), 0 0 3px var(--bg);
}
.lg-row { display: flex; flex-wrap: wrap; gap: 0 10px; white-space: nowrap; }
.lg-row b { font-weight: 500; }
.lg-sym { font-weight: 700; font-size: 14px; color: #fff; }
.lg-sym small { font-weight: 500; font-size: 11px; color: var(--muted); }
.lg-int, .lg-src { color: var(--muted); }
.lg-ohlc { display: inline-flex; gap: 6px; }
.lg-vol { color: var(--muted); }
.lg-24h { font-weight: 500; }
.lg-ind { margin-top: 1px; }
.lg-ind span { color: var(--muted); }

.panel-msg[hidden] { display: none; }
.panel-msg {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 4;
  color: var(--muted); background: rgba(19,23,34,.6); font-size: 13px; padding: 16px; text-align: center;
}

/* ── 토스트 ── */
#toasts { position: fixed; right: 12px; bottom: 12px; z-index: 50; display: flex; flex-direction: column; gap: 6px; }
.toast {
  background: var(--bg2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  color: #fff; padding: 9px 12px; border-radius: 6px; font-size: 13px; max-width: 320px;
  opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.toast.show { opacity: 1; transform: none; }
.toast.err { border-left-color: var(--down); }
.toast.alert { border-left-color: var(--warn); }

/* ── 모바일 ── */
@media (max-width: 820px) {
  #panels[data-layout="2h"] { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .brand { display: none; }
  .lg-ohlc .kv:nth-child(-n+3) { display: none; }
  .lg-src, .lg-vol { display: none; }
}
@media (max-width: 520px) {
  #rail { width: 34px; }
  .sym-krw { display: none; }
  .legend { font-size: 11px; }
}
