/* Trading Arena
 *
 * 디자인 토큰
 *   표면     : 차가운 근흑색 캔버스 위에 3단계 표면 (panel → panel-2 → panel-3), 테두리는 머리카락 두께
 *   강조색   : 아레나 골드 하나만 쓴다 (주요 버튼·활성 탭·포커스·1위). 그 위 글자는 어두운 잉크색
 *   가격 방향: 상승 빨강 / 하락 파랑 (국내 관례). 가격 방향 표시에만 쓰고 장식에는 쓰지 않는다
 *   숫자     : Pretendard 고정폭 숫자(tabular-nums). JetBrains Mono는 코드·콘솔에만
 *   모서리   : 컨테이너 14px · 컨트롤 10px · 칩/태그 6px
 *   움직임   : transform·opacity만, 160–320ms, prefers-reduced-motion이면 끈다
 */
@import url('/fonts/pretendard/pretendardvariable-dynamic-subset.css');
@import url('/fonts/jetbrains-mono/jetbrains-mono.css');

:root {
  --bg: #0a0c10;
  --panel: #10131a;
  --panel-2: #161a23;
  --panel-3: #1c212c;
  --border: #1d222d;
  --border-strong: #2a303d;
  --text: #e8ebf1;
  --muted: #8a92a4;
  --faint: #5b6375;

  --up: #f04452;
  --up-bg: rgba(240, 68, 82, 0.12);
  --down: #3e86f6;
  --down-bg: rgba(62, 134, 246, 0.13);

  --accent: #e7b84a;
  --accent-hover: #f0c560;
  --accent-ink: #17130a;
  --accent-soft: rgba(231, 184, 74, 0.12);
  --accent-line: rgba(231, 184, 74, 0.45);

  --ok: #2ebd73;
  --ok-bg: rgba(46, 189, 115, 0.12);
  --warn: #ef8d3c;
  --warn-bg: rgba(239, 141, 60, 0.12);

  --radius-lg: 14px;
  --radius: 10px;
  --radius-sm: 6px;
  --header-h: 60px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025), 0 12px 32px -18px rgba(1, 3, 10, 0.9);

  --sans: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, sans-serif;
  --mono: 'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; } /* iOS 글자 자동 확대 끔 */
a, button, input, select, textarea, label, .watch-row { touch-action: manipulation; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.num, .mono { font-family: var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.code-font { font-family: var(--mono); font-size: 12px; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.center { text-align: center; }
.right { text-align: right; }
.hidden { display: none !important; }

.skip-link { position: absolute; left: 12px; top: -48px; z-index: 30; padding: 8px 12px; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); font-weight: 700; transition: top 160ms var(--ease); }
.skip-link:focus { top: 10px; }

/* ───────── 헤더 ───────── */
#header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 28px;
  height: var(--header-h); padding: 0 22px;
  background: rgba(10, 12, 16, 0.86);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}
#header > .tag { white-space: nowrap; flex: none; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 16px; letter-spacing: -0.03em; flex: none; }
.logo svg { display: block; }
#nav { display: flex; gap: 2px; align-self: stretch; }
#nav a {
  position: relative; display: flex; align-items: center;
  padding: 0 14px; color: var(--muted); font-weight: 600; white-space: nowrap;
  transition: color 160ms var(--ease);
}
#nav a::after {
  content: ''; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px; border-radius: 2px;
  background: var(--accent); transform: scaleX(0); transition: transform 240ms var(--ease);
}
#nav a:hover { color: var(--text); }
#nav a.active { color: var(--text); }
#nav a.active::after { transform: scaleX(1); }
#header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.account-badge { display: flex; gap: 18px; margin-right: 4px; padding-right: 16px; border-right: 1px solid var(--border); }
.badge-col { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.badge-col strong { font-size: 13px; font-weight: 650; letter-spacing: -0.01em; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px 0 4px;
  border-radius: var(--radius); background: var(--panel-2); font-weight: 600; white-space: nowrap;
  transition: background 160ms var(--ease);
}
.user-chip:hover { background: var(--panel-3); }

/* 이니셜 아바타 (모서리가 둥근 사각형, 이름에서 색 결정) */
.avatar {
  --h: 220;
  display: inline-grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 8px;
  background: hsl(var(--h) 32% 20%); color: hsl(var(--h) 75% 80%);
  font-size: 11px; font-weight: 750; letter-spacing: -0.02em; line-height: 1;
  box-shadow: inset 0 0 0 1px hsl(var(--h) 40% 30% / 0.6);
}
.avatar { position: relative; overflow: hidden; }
.avatar.photo { color: transparent; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.avatar.lg { width: 44px; height: 44px; border-radius: 12px; font-size: 16px; }
.avatar.xxl { width: 112px; height: 112px; border-radius: 28px; font-size: 38px; }
.avatar-preview { display: grid; place-items: center; padding: 8px 0 4px; }
.avatar-actions { display: flex; justify-content: center; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.avatar-btn { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 12px; transition: transform 160ms var(--ease), box-shadow 160ms var(--ease); }
.avatar-btn:hover { box-shadow: 0 0 0 2px var(--accent-line); }
.avatar-btn:active { transform: scale(0.96); }
.avatar.xl { width: 56px; height: 56px; border-radius: 15px; font-size: 20px; }

/* ───────── 버튼·입력 ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: var(--radius); border: 1px solid transparent;
  background: var(--panel-2); font-weight: 650; cursor: pointer; white-space: nowrap;
  transition: background 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease), transform 120ms var(--ease), opacity 160ms;
}
.btn:hover { background: var(--panel-3); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.xs { height: 26px; padding: 0 9px; font-size: 12px; border-radius: var(--radius-sm); }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--panel-2); border-color: var(--faint); }
.btn.buy { background: var(--up); color: #fff; }
.btn.buy:hover { background: #f25764; }
.btn.sell { background: var(--down); color: #fff; }
.btn.sell:hover { background: #5294f7; }
.btn.danger { background: transparent; border-color: rgba(240, 68, 82, 0.45); color: #ff7480; }
.btn.danger:hover { background: var(--up-bg); }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 0 12px; height: 40px; outline: none; min-width: 0;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: #363d4d; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 18px 12px; font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 650; background: var(--panel-3); color: var(--muted); white-space: nowrap; }
.tag.live { background: var(--ok-bg); color: var(--ok); }
.tag.delay { background: var(--warn-bg); color: var(--warn); }
.tag.closed { background: var(--panel-3); color: var(--muted); }
.tag.bot { background: var(--accent-soft); color: var(--accent); }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.open { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot.delay { background: var(--warn); }
.dot.stale { background: var(--up); }

.tabs { flex: none; display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs button {
  position: relative; background: none; border: 0; padding: 13px 10px; color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: color 160ms var(--ease);
}
.tabs button::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--text); transform: scaleX(0); transition: transform 240ms var(--ease); }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); }
.tabs button.active::after { transform: scaleX(1); }
.tabs .count { margin-left: 4px; font-size: 11px; color: var(--faint); }

.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; }
.seg button { background: none; border: 0; padding: 5px 11px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 12px; cursor: pointer; transition: background 160ms var(--ease), color 160ms var(--ease); }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--panel-3); color: var(--text); }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { position: sticky; top: 0; z-index: 1; background: var(--panel); color: var(--faint); font-weight: 600; font-size: 12px; text-align: right; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.grid td { padding: 10px 12px; text-align: right; border-bottom: 1px solid rgba(255, 255, 255, 0.035); white-space: nowrap; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid th:first-child, table.grid td:first-child { text-align: left; }
table.grid td.text { font-family: var(--sans); }
table.grid tr.clickable { cursor: pointer; }
table.grid tr td { transition: background 120ms; }
table.grid tr.clickable:hover td { background: var(--panel-2); }
.table-wrap { overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
/* 청산·취소 버튼 열은 표가 가로로 넘쳐도 오른쪽에 붙어 있다 */
table.grid th.act, table.grid td.act { position: sticky; right: 0; background: var(--panel); box-shadow: -12px 0 12px -10px rgba(0, 0, 0, 0.6); }
table.grid th.act { z-index: 2; }
table.grid tr.clickable:hover td.act { background: var(--panel-2); }
.sym-cell { display: flex; align-items: center; gap: 10px; }
.sym-cell .mark { width: 30px; height: 30px; font-size: 10px; }
.tag.long { background: var(--up-bg); color: var(--up); }
.tag.short { background: var(--down-bg); color: var(--down); }
.console-empty { color: var(--faint); font-family: var(--sans); padding: 18px 2px; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); line-height: 1.6; }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* 화면 진입: 패널이 아래에서 살짝 올라오며 나타난다 */
@media (prefers-reduced-motion: no-preference) {
  /* 처음 그릴 때만 (.enter). 주기적인 갱신은 숫자만 굴러간다 */
  #main > *, .enter > * { animation: rise 420ms var(--ease) both; }
  #main > *:nth-child(2), .enter > *:nth-child(2) { animation-delay: 40ms; }
  #main > *:nth-child(3), .enter > *:nth-child(3) { animation-delay: 80ms; }
  #main > *:nth-child(4), .enter > *:nth-child(4) { animation-delay: 120ms; }
  #main > *:nth-child(5), .enter > *:nth-child(5) { animation-delay: 160ms; }
  #main > *:nth-child(n+6), .enter > *:nth-child(n+6) { animation-delay: 200ms; }
}

/* 롤링 숫자: 자리마다 0~9 세로 띠가 위아래로 굴러간다 (roll.js) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* 보이지 않는 글자(::before)가 기준선을 만들어, 주변 글자와 기준선이 정확히 맞는다 */
.roll { position: relative; display: inline-block; line-height: 1.15; white-space: nowrap; }
.roll::before { content: '\200b'; }
.roll-vis { display: inline-flex; overflow: hidden; vertical-align: top; }
.roll-vis.rolling .rd { -webkit-mask-image: linear-gradient(transparent, #000 24%, #000 76%, transparent); mask-image: linear-gradient(transparent, #000 24%, #000 76%, transparent); }
.rd { position: relative; display: block; overflow: hidden; }
.rh { display: block; visibility: hidden; } /* 숫자 한 줄: 자리의 너비·높이 */
.rs { position: absolute; left: 0; top: 0; width: 100%; display: block; white-space: pre; text-align: center; will-change: transform; }
.rc { display: block; white-space: pre; }

/* 순위가 바뀐 행: 새 자리로 미끄러져 가며 잠깐 강조 */
@keyframes rankMoved { from { background: var(--accent-soft); } to { background: transparent; } }
tr.moved td { animation: rankMoved 1.6s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ───────── 트레이딩 화면 ───────── */
.page-trade {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 330px;
  gap: 10px; padding: 10px;
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h)); /* iPad·iPhone Safari: 주소창·탭 막대를 뺀 실제 보이는 높이 */
}
.page-trade > * { min-width: 0; }
.watchlist { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.watchlist > .tabs, .watchlist .search { flex: none; }
.watchlist .search { margin: 12px 12px 6px; height: 36px; background: var(--panel-2); border-color: transparent; }
.watchlist .search:focus { background: var(--bg); }
.watch-body { overflow-y: auto; flex: 1; min-height: 0; padding-bottom: 8px; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.watch-group { padding: 16px 16px 6px; font-size: 12px; font-weight: 650; color: var(--faint); }
.watch-sector { width: calc(100% - 16px); background: none; border: 0; color: inherit; text-align: left; display: flex; justify-content: space-between; align-items: center; margin: 2px 8px; padding: 9px 10px; border-radius: var(--radius); cursor: pointer; font-weight: 600; font-size: 13px; user-select: none; transition: background 120ms; }
.watch-sector:hover { background: var(--panel-2); }
.watch-row {
  position: relative;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto; gap: 1px 10px; align-items: center;
  margin: 1px 8px; padding: 8px 10px; border-radius: var(--radius); cursor: pointer;
  transition: background 120ms;
  content-visibility: auto; contain-intrinsic-size: auto 52px; /* 긴 목록: 화면 밖 행은 그리지 않는다 */
}
.watch-row:hover { background: var(--panel-2); }
.watch-row.active { background: var(--panel-3); }
.watch-row.active::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--accent); }
.watch-row .mark { grid-row: 1 / 3; }
.watch-row .sym { font-weight: 700; display: flex; align-items: center; gap: 6px; letter-spacing: -0.01em; min-width: 0; }
.watch-row .nm { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-row .px { text-align: right; font-size: 13px; font-weight: 600; }
.watch-row .chg { justify-self: end; font-size: 11px; font-weight: 650; padding: 1px 6px; border-radius: 5px; background: var(--panel-3); color: var(--muted); }
.watch-row .chg.up { background: var(--up-bg); color: var(--up); }
.watch-row .chg.down { background: var(--down-bg); color: var(--down); }
.watch-row .chg:empty { display: none; }
.flash-up { animation: flashUp 0.7s; }
.flash-down { animation: flashDown 0.7s; }
@keyframes flashUp { from { background: var(--up-bg); } to { background: transparent; } }
@keyframes flashDown { from { background: var(--down-bg); } to { background: transparent; } }

/* 종목 기호 (심볼 앞글자, 자산군별 색) */
.mark {
  --h: 220;
  position: relative; display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: hsl(var(--h) 28% 17%); color: hsl(var(--h) 70% 78%);
  font-size: 11px; font-weight: 750; letter-spacing: -0.03em;
}
.mark .dot { position: absolute; right: -2px; bottom: -2px; width: 8px; height: 8px; border: 2px solid var(--panel); box-shadow: none; }
.watch-row:hover .mark .dot { border-color: var(--panel-2); }
.watch-row.active .mark .dot { border-color: var(--panel-3); }
.mark.lg { width: 44px; height: 44px; border-radius: 12px; font-size: 14px; }

.center-col { display: grid; grid-template-rows: auto minmax(260px, 1fr) minmax(200px, 34%); gap: 10px; min-height: 0; }
.inst-head { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 14px 32px; padding: 16px 20px; }
.inst-head .title { display: flex; align-items: center; gap: 12px; }
.inst-head .title h1 { margin: 0; font-size: 20px; font-weight: 750; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.inst-head .title .muted { margin-top: 2px; }
.inst-head .quote-block { display: flex; align-items: baseline; gap: 10px; }
.inst-head .price { font-size: 30px; font-weight: 750; letter-spacing: -0.03em; line-height: 1; }
.inst-head .stats { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 0; padding-top: 12px; border-top: 1px solid var(--border); }
.inst-head .stat { display: flex; flex-direction: column; gap: 3px; font-size: 12px; padding: 0 20px; border-left: 1px solid var(--border); }
.inst-head .stat:first-child { padding-left: 0; border-left: 0; }
.inst-head .stat > span:first-child { color: var(--faint); }
.inst-head .stat > span:last-child { font-size: 13px; font-weight: 600; }
.chg-pill { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 650; background: var(--panel-3); color: var(--muted); white-space: nowrap; }
.chg-pill.up { background: var(--up-bg); color: var(--up); }
.chg-pill.down { background: var(--down-bg); color: var(--down); }
.chart-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chart-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.chart-box { flex: 1; min-height: 0; position: relative; overflow: hidden; } /* 차트 캔버스가 패널 밖(주문 창 쪽)으로 그려지지 않게 */
.chart-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
.bottom-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.bottom-panel .table-wrap { flex: 1; min-height: 0; }

.right-col { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.order-form { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.side-toggle { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 12px; padding: 4px; border: 1px solid var(--border); }
.side-toggle button { height: 38px; border: 0; border-radius: 9px; background: none; font-weight: 750; color: var(--muted); cursor: pointer; transition: background 200ms var(--ease), color 200ms var(--ease); }
.side-toggle button:hover { color: var(--text); }
.side-toggle button.buy.active { background: var(--up); color: #fff; }
.side-toggle button.sell.active { background: var(--down); color: #fff; }
.qty-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.qty-row button { height: 30px; border: 1px solid var(--border); background: var(--panel-2); border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; transition: color 120ms, border-color 120ms, transform 120ms var(--ease); }
.qty-row button:hover { color: var(--text); border-color: var(--border-strong); }
.qty-row button:active { transform: scale(0.97); }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 2px 0; }
.kv > span:first-child { color: var(--muted); }
.kv > span:last-child { font-weight: 600; }
.notice { font-size: 12px; line-height: 1.55; padding: 10px 12px; border-radius: var(--radius); background: var(--panel-2); color: var(--muted); }
.notice.warn { background: var(--warn-bg); color: #f3a868; }
.acct-card { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.acct-card .big { font-size: 24px; font-weight: 750; letter-spacing: -0.03em; }
.pos-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 5px; }

/* ───────── 랭킹 ───────── */
.page-rank, .page-account, .page-user, .page-api { max-width: 1200px; margin: 0 auto; padding: 32px 24px 72px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 6px; font-size: 30px; font-weight: 750; letter-spacing: -0.035em; line-height: 1.15; display: flex; align-items: center; gap: 12px; }
.page-head .muted { max-width: 65ch; text-wrap: pretty; }

/* 1위는 크게, 2·3위는 옆에 쌓는다 */
.podium { display: grid; grid-template-columns: 1.35fr 1fr; grid-template-rows: auto auto; gap: 10px; margin-bottom: 14px; }
.podium .card { position: relative; overflow: hidden; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 16px 18px; transition: border-color 200ms var(--ease), transform 200ms var(--ease); }
.podium .card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.podium .card.first { grid-row: 1 / 3; grid-template-columns: 1fr; align-content: space-between; gap: 18px; padding: 22px 24px; border-color: var(--accent-line); background: radial-gradient(120% 90% at 100% 0%, rgba(231, 184, 74, 0.10), transparent 55%), var(--panel); }
.podium .who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.podium .name { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .first .name { font-size: 20px; }
.podium .ret { font-size: 22px; font-weight: 750; letter-spacing: -0.03em; text-align: right; }
.podium .first .ret { font-size: 44px; text-align: left; line-height: 1; }
.podium .sub { color: var(--muted); font-size: 12px; }
.podium .first-meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.place { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; font-weight: 800; font-size: 13px; background: var(--panel-3); color: var(--muted); flex: none; }
.place.p1 { background: var(--accent); color: var(--accent-ink); }
.place.p2 { background: #2a2f3a; color: #d9dde6; }
.place.p3 { background: #33261b; color: #e3a77a; }
tr.me td { background: var(--accent-soft); }
tr.me:hover td { background: rgba(231, 184, 74, 0.16) !important; }
.rank-num { display: inline-block; min-width: 24px; font-weight: 750; color: var(--muted); }
.rank-num.top { color: var(--accent); }
.trader { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; }

/* ───────── 계좌·프로필 ───────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.cards.hero { grid-template-columns: 1.6fr repeat(2, 1fr); grid-auto-rows: auto; }
.cards.hero > .stat-card.lead { grid-row: span 2; justify-content: space-between; padding: 22px 24px; background: radial-gradient(110% 80% at 100% 0%, rgba(231, 184, 74, 0.08), transparent 60%), var(--panel); }
.cards.hero > .stat-card.lead .value { font-size: 36px; }
.stat-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.stat-card .label { font-size: 12px; color: var(--muted); }
.stat-card .value { font-size: 21px; font-weight: 750; letter-spacing: -0.03em; }
.stat-card .foot { font-size: 13px; font-weight: 600; }
.equity-chart { height: 300px; }
.alloc { display: flex; flex-direction: column; gap: 12px; padding: 4px 18px 18px; }
.alloc-row { display: grid; grid-template-columns: 90px 1fr 110px; gap: 12px; align-items: center; font-size: 13px; }
.bar { height: 6px; border-radius: 3px; background: transparent; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 3px; }
.section { margin-bottom: 14px; }

/* ───────── 알고리즘 ───────── */
.page-algo { display: grid; grid-template-columns: 250px minmax(0, 1fr) 340px; gap: 10px; padding: 10px; height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h)); }
.script-list { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.script-item { position: relative; margin: 1px 8px; padding: 11px 12px; border-radius: var(--radius); cursor: pointer; display: flex; flex-direction: column; gap: 3px; transition: background 120ms; }
.script-item:hover { background: var(--panel-2); }
.script-item.active { background: var(--panel-3); }
.script-item.active::before { content: ''; position: absolute; left: -8px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.script-item .row { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.editor-col { display: grid; grid-template-rows: auto minmax(0, 1fr) 230px; gap: 10px; min-height: 0; }
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; }
.editor-toolbar input.name { flex: 1; min-width: 120px; font-weight: 700; }
.editor-toolbar select { width: auto; }
.editor-toolbar input.interval { width: 80px; }
.editor-box { min-height: 0; overflow: hidden; }
.editor-box .CodeMirror { height: 100%; font-family: var(--mono); font-size: 13px; background: #0c0f14; }
.editor-box .CodeMirror-gutters { background: #0c0f14; border-right: 1px solid var(--border); }
.editor-box .CodeMirror-cursor { border-left-color: var(--accent); }
.console { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.editor-col.perf-open { grid-template-rows: auto minmax(140px, 0.7fr) minmax(0, 1.3fr); }
.perf-body { flex: 1; overflow-y: auto; padding: 10px 14px 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.kpi { background: var(--panel-2); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 11px; color: var(--muted); }
.kpi .value { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; }
.perf-section { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.perf-head { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.perf-chart { height: 200px; padding: 4px; }
.console-body { flex: 1; overflow-y: auto; font-family: var(--mono); font-size: 12px; padding: 8px 14px 14px; line-height: 1.65; }
.console-body .ln { white-space: pre-wrap; word-break: break-all; }
.console-body .ln .ts { color: var(--faint); margin-right: 8px; }
.ln.error { color: #ff7b86; }
.ln.warn { color: #f3a868; }
.ln.trade { color: #6fd6a0; }
.ln.system { color: var(--accent); }
.docs { overflow-y: auto; padding: 4px 18px 22px; font-size: 13px; line-height: 1.65; }
.docs h3 { font-size: 13px; margin: 20px 0 6px; color: var(--text); }
.docs code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.docs dl { margin: 0; }
.docs dt { font-family: var(--mono); font-size: 12px; color: var(--accent); margin-top: 10px; }
.docs dd { margin: 2px 0 0; color: var(--muted); }
.docs p { color: var(--muted); margin: 6px 0; }

/* 코드 블록 */
.code-wrap { position: relative; margin: 8px 0; }
.code-wrap .copy { position: absolute; top: 8px; right: 8px; background: var(--panel); }
pre.code { margin: 0; padding: 14px 16px; padding-right: 64px; background: #0c0f14; border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--mono); font-size: 12px; line-height: 1.65; color: var(--text); overflow-x: auto; white-space: pre; }

/* ───────── 모달·토스트 ───────── */
.modal-backdrop { overscroll-behavior: contain; position: fixed; inset: 0; z-index: 50; background: rgba(4, 6, 10, 0.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; }
.modal { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--border-strong); border-radius: 18px; padding: 28px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7); }
@media (prefers-reduced-motion: no-preference) {
  .modal-backdrop { animation: fade 200ms var(--ease) both; }
  .modal { animation: pop 320ms var(--ease) both; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form h2 { margin: 0; font-size: 22px; font-weight: 750; letter-spacing: -0.03em; }
.auth-form p { margin: 0; }
.auth-form .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.auth-form input { height: 44px; }
.auth-form .btn.block { height: 44px; margin-top: 4px; }
.form-error { color: #ff7480; font-size: 13px; min-height: 18px; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { padding: 12px 16px 12px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--border-strong); border-left: 3px solid var(--faint); box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.6); transition: opacity 0.4s, transform 0.4s var(--ease); font-size: 13px; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise 320ms var(--ease) both; } }
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--up); }
.toast.info { border-left-color: var(--accent); }
.toast.hide { opacity: 0; transform: translateY(8px); }

/* ───────── 반응형 ───────── */
@media (max-width: 1200px) {
  .page-trade { grid-template-columns: 260px minmax(0, 1fr) 296px; }
  .page-algo { grid-template-columns: 210px minmax(0, 1fr); }
  .page-algo .docs-panel { display: none; }
  .inst-head .stats { margin-left: 0; }
}
@media (max-width: 1080px) {
  .account-badge { display: none; } /* 헤더가 넘쳐 로그아웃 버튼이 화면 밖으로 밀리지 않게 (순자산은 오른쪽 계좌 카드에 있음) */
}
@media (max-width: 900px) {
  :root { --header-h: auto; }
  /* 헤더 두 줄: 로고·계정 / 메뉴 (메뉴는 가로 스크롤) */
  #header { flex-wrap: wrap; gap: 0 10px; padding: 8px 12px 0; height: auto; }
  #header-right { order: 2; }
  #nav { order: 3; flex: 1 0 100%; height: 42px; overflow-x: auto; scrollbar-width: none; margin: 4px -12px 0; padding: 0 2px; }
  #nav a { padding: 0 12px; }
  #nav a::after { left: 12px; right: 12px; }
  .user-chip span:not(.avatar) { display: none; }
  .user-chip { padding: 0 4px; }
  .page-trade, .page-algo { display: flex; flex-direction: column; height: auto; padding: 8px; }
  .watchlist { max-height: 320px; }
  .center-col { display: flex; flex-direction: column; }
  .chart-panel { height: 380px; }
  .bottom-panel { max-height: 420px; }
  .inst-head { grid-template-columns: 1fr; padding: 14px 16px; gap: 12px; }
  .inst-head .price { font-size: 26px; }
  .editor-col { display: flex; flex-direction: column; }
  .editor-box { height: 420px; }
  .console { height: 240px; }
  .script-list { max-height: 220px; }
  .podium { grid-template-columns: 1fr; }
  .podium .card.first { grid-row: auto; }
  .podium .first .ret { font-size: 36px; }
  .cards.hero { grid-template-columns: 1fr 1fr; }
  .cards.hero > .stat-card.lead { grid-column: 1 / -1; grid-row: auto; }
  .page-rank, .page-account, .page-user, .page-api { padding: 20px 12px 48px; }
  .page-head h1 { font-size: 24px; }
}
