/* Paperex — exchange demo dark theme
 * Colors: up=green, down=red (international convention). Brand gold = #e8b339.
 * Semantic vars: everything bullish/buy uses --up, bearish/sell uses --down — flip here to reskin globally. */
:root {
  --bg: #070a0e;
  --panel: #0f141a;
  --panel-2: #151b23;
  --panel-3: #1a212b;
  --line: #1d242d;
  --line-2: #2a323d;
  --txt: #e2e8f0;
  --muted: #828d9a;
  --dim: #5a636e;
  --up: #16c784;       /* up/buy (international: green) */
  --up-soft: rgba(22, 199, 132, .13);
  --down: #ea3943;     /* down/sell (international: red) */
  --down-soft: rgba(234, 57, 67, .13);
  --gold: #e8b339;
  --gold-soft: rgba(232, 179, 57, .14);
  --green: #2fb344;
  --radius: 11px;
  --radius-sm: 7px;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 0 rgba(255,255,255,.02) inset, 0 8px 24px -16px rgba(0,0,0,.8);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 78% -10%, rgba(232,179,57,.05), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(28,126,214,.05), transparent 55%),
    var(--bg);
  color: var(--txt);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
        "Malgun Gothic", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.1px; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--muted); }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 9px;
  gap: 9px;
}

/* ══ Top bar ══ */
.topbar {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: linear-gradient(180deg, #121821, var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 6px 0 16px;
  height: 62px;
  flex: 0 0 auto;
  box-shadow: var(--shadow);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 17px; letter-spacing: .3px; white-space: nowrap;
  padding-right: 18px;
}
.brand b { font-weight: 700; }
.brand i { color: var(--gold); font-style: normal; }
.sim-badge {
  margin-left: 10px; padding: 3px 9px; border-radius: 999px;
  font-size: 10px; font-weight: 800; letter-spacing: .4px; white-space: nowrap;
  background: var(--gold-soft); color: var(--gold); border: 1px solid rgba(232,179,57,.35);
  cursor: help;
}
.sim-disclaimer {
  margin: 2px auto 10px; max-width: 92vw; width: max-content;
  padding: 6px 16px; border-radius: 999px;
  background: rgba(20,22,28,.92); border: 1px solid var(--line-2);
  color: var(--muted); font-size: 11px; line-height: 1.4; text-align: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.4); pointer-events: none;
}

/* ── SEO/GEO footer: crawlable About + FAQ (real, visible content) ── */
.site-foot { max-width: 1120px; margin: 16px auto 0; padding: 24px 18px 8px; border-top: 1px solid var(--line); }
.foot-in { display: grid; grid-template-columns: 1.5fr 1fr; gap: 30px; }
.foot-about h1 { font-size: 18px; color: var(--txt); margin: 0 0 10px; font-weight: 700; }
.foot-about p { font-size: 13px; line-height: 1.65; margin: 0 0 12px; color: var(--muted); }
.foot-feat { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.75; color: var(--muted); }
.foot-faq h2 { font-size: 14px; color: var(--txt); margin: 0 0 8px; font-weight: 700; }
.foot-faq details { border-bottom: 1px solid var(--line); padding: 8px 0; }
.foot-faq summary { cursor: pointer; font-size: 13px; color: var(--txt); font-weight: 600; list-style: none; }
.foot-faq summary::-webkit-details-marker { display: none; }
.foot-faq summary::before { content: '+ '; color: var(--gold); font-weight: 800; }
.foot-faq details[open] summary::before { content: '− '; }
.foot-faq details p { font-size: 12.5px; line-height: 1.6; margin: 8px 0 0; color: var(--muted); }
.foot-legal { max-width: 1120px; margin: 14px auto 0; padding: 0 18px 36px; font-size: 11px; color: var(--dim); text-align: center; line-height: 1.5; }
@media (max-width: 720px) { .foot-in { grid-template-columns: 1fr; gap: 18px; } }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #f5c759, #b9831f);
  color: #1a1205; font-weight: 800; font-size: 16px;
  box-shadow: 0 2px 10px -2px rgba(232,179,57,.5);
}

.sympick {
  display: flex; align-items: center; gap: 11px;
  padding: 0 14px; margin: 11px 0;
  border-radius: var(--radius-sm);
  background: var(--panel-2); border: 1px solid var(--line);
  cursor: pointer; white-space: nowrap;
  transition: border-color .15s, background .15s;
}
.sympick:hover { border-color: var(--line-2); background: var(--panel-3); }
.sympick .star { color: var(--gold); font-size: 14px; }
.sympick .nm { display: flex; flex-direction: column; line-height: 1.2; }
.sympick .nm b { font-size: 14px; font-weight: 700; }
.sympick .nm small { color: var(--muted); font-size: 11px; font-family: var(--mono); }
.sympick .caret { color: var(--dim); font-size: 9px; transition: transform .15s; }
.sympick.open .caret { transform: rotate(180deg); }
.sym-menu {
  position: fixed; z-index: 10000; max-height: 60vh; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px -8px rgba(0,0,0,.7); padding: 5px;
}
.sym-menu[hidden] { display: none; }
.sym-menu-row {
  display: flex; align-items: baseline; gap: 8px; padding: 7px 10px;
  border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.sym-menu-row:hover { background: var(--panel-3); }
.sym-menu-row.on { background: var(--gold-soft); }
.sym-menu-row b { font-size: 13px; font-weight: 700; min-width: 46px; }
.sym-menu-row .nm { flex: 1; color: var(--txt); font-size: 12px; }
.sym-menu-row small { color: var(--muted); font-size: 11px; font-family: var(--mono); }

.ticker { display: flex; align-items: center; flex: 1; min-width: 0; overflow: hidden; }
.ticker .big {
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 22px 0 20px; white-space: nowrap;
}
.ticker .big .price { font-size: 25px; font-weight: 800; line-height: 1.05; letter-spacing: -.4px; }
.ticker .big .sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.ticker .stat {
  display: flex; flex-direction: column; justify-content: center; gap: 3px;
  padding: 0 20px; white-space: nowrap;
  border-left: 1px solid var(--line);
}
.ticker .stat .k { color: var(--dim); font-size: 10.5px; letter-spacing: .2px; text-transform: uppercase; }
.ticker .stat .v { font-size: 13px; font-weight: 600; }
.ticker .chg {
  display: flex; flex-direction: column; justify-content: center; gap: 3px;
  padding: 0 20px 0 0; white-space: nowrap;
}
.ticker .chg .pct { font-size: 15px; font-weight: 700; }
.ticker .chg .amt { font-size: 11.5px; }

/* Countdown to the next economic indicator (header) — clicking it slides the economic-calendar drawer up. */
.next-econ {
  display: flex; flex-direction: column; justify-content: center; gap: 3px;
  padding: 0 18px; white-space: nowrap;
  border: 0; border-left: 1px solid var(--line);
  background: none; color: inherit; text-align: left;
  transition: background .15s;
}
.next-econ:hover { background: var(--gold-soft); }
.next-econ .ne-k { color: var(--dim); font-size: 10.5px; letter-spacing: .2px; text-transform: uppercase; }
.next-econ .ne-co { color: var(--muted); text-transform: none; }
.next-econ .ne-flag { width: 16px; height: 12px; border-radius: 2px; object-fit: cover; vertical-align: -1px; box-shadow: 0 0 0 1px rgba(255,255,255,.14); }
.next-econ .ne-v { display: flex; align-items: center; gap: 8px; }
.next-econ .ne-imp { flex: 0 0 auto; }
.next-econ .ne-imp i { width: 3px; }
.next-econ .ne-imp i.h1 { height: 5px; } .next-econ .ne-imp i.h2 { height: 8px; } .next-econ .ne-imp i.h3 { height: 11px; }
/* slide the next-event row up when the event changes (ticker-style refresh) */
@keyframes neRise { from { transform: translateY(115%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.next-econ .ne-v.rise { animation: neRise .45s cubic-bezier(.22,.61,.36,1); }
.next-econ .ne-v b {
  display: inline-block; vertical-align: bottom; white-space: nowrap;
  font-size: 12.5px; font-weight: 700; color: var(--txt);
}
.next-econ .ne-cd { color: var(--gold); font-size: 12px; font-weight: 800; }
.next-econ[hidden] { display: none; }

.conn {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 8px;
  padding: 0 14px 0 18px; margin-left: auto; white-space: nowrap;
  border-left: 1px solid var(--line);
}
.conn .mode {
  font-size: 10.5px; font-weight: 800; letter-spacing: .6px;
  padding: 3px 11px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
}
.conn .mode::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  box-shadow: 0 0 7px currentColor;
}
.conn .mode.sim { background: var(--gold-soft); color: var(--gold); }
.conn .mode.live { background: rgba(47,179,68,.16); color: var(--green); }
.conn .dots { display: flex; gap: 13px; color: var(--muted); font-size: 11px; }
.conn .dots span { display: flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); transition: background .2s, box-shadow .2s; }
.dot.on { background: var(--green); box-shadow: 0 0 7px rgba(47,179,68,.7); }

/* ══ Three stacked bands — everything visible at once ══
   Row 1: core trading (markets · chart · book · form)
   Row 2: account (open · filled · positions · assets)
   Row 3: market intel (calendar · news · forecast) */
.grid-main {
  flex: 0 0 auto;
  /* Definite height (viewport minus the two lower bands + chrome) so inner panels with
     min-height:0/overflow resolve correctly and the chart can't run away to max-content. */
  height: calc(100vh - 540px);
  min-height: 480px;
  display: grid;
  /* side · 차트(1fr, 나머지) · 호가창 · 체결내역(호가창 옆) · 주문폼 — 체결탭 컬럼이 생기며 차트가 줄어든다. */
  grid-template-columns: 208px minmax(0, 1fr) 256px 216px 288px;
  grid-template-rows: minmax(0, 1fr);
  gap: 9px;
}
.grid-main .side { min-height: 0; }
.grid-main .chart { min-height: 0; }
.grid-main .book { min-height: 0; }
.form { display: flex; flex-direction: column; gap: 9px; min-height: 0; }
/* 주문폼 패널이 체결탭보다 큰 세로 비중(2:1). form-body 만 스크롤하고 매수/매도 버튼은 패널 하단에 고정. */
.form > .panel:not(.tape-panel) { flex: 2 1 0; min-width: 0; }

.grid-account {
  flex: 0 0 auto;
  height: 208px;
  display: grid;
  /* Open+Filled 을 한 탭 패널로 합쳐 3컬럼: [주문(미체결/체결 탭)] · 포지션 · 자산 */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  gap: 9px;
}
/* 주문 패널 탭(미체결/체결) — 헤더를 버튼 두 개로 */
.acct .acct-tabs { padding: 0; gap: 0; }
.acct .otab-btn {
  flex: 1; padding: 11px 10px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 12.5px; font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 6px; justify-content: center;
}
.acct .otab-btn.on { color: var(--txt); border-bottom-color: var(--gold); }
.acct .otab-btn:first-child { border-right: 1px solid var(--line); }
.acct .otab-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.acct .otab-pane[hidden] { display: none; }
.grid-intel {
  flex: 0 0 auto;
  height: 312px;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr) minmax(0, 1.1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 9px;
}

/* ── Account band (always-on; replaces the old tabbed bottom panel) ── */
.acct .ph { justify-content: space-between; }
.acct .ph .cnt {
  padding: 1px 8px; font-size: 11px; font-weight: 700;
  background: var(--gold-soft); border-radius: 999px; color: var(--gold);
}
.acct-head {
  display: grid; align-items: center; gap: 8px;
  padding: 6px 13px; color: var(--dim); font-size: 10px;
  letter-spacing: .3px; text-transform: uppercase;
  border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.acct-head.ord { grid-template-columns: 52px 1fr 1fr 1.1fr; }
.acct-head.bal { grid-template-columns: 1fr 1fr 1fr; }
.acct-head.ord span:nth-child(n+2), .acct-head.bal span:nth-child(n+2) { text-align: right; }
.acct-body { flex: 1; overflow-y: auto; padding: 3px 0; min-height: 0; }

/* ── Intel band (always-on; replaces the old slide-up drawer) ── */
.intel { min-height: 0; }
.intel .ph { gap: 8px; }
.intel .ph h2 { white-space: nowrap; }
.intel-body { flex: 1; min-height: 0; overflow-y: auto; position: relative; }
.cal-panel .intel-body { display: flex; flex-direction: column; }
.news-panel .ph { justify-content: space-between; }
.news-panel .news-tabs { padding: 0; border: 0; background: none; }
.news-feed { overflow: auto; }

/* self-rendered news list */
.news-list { padding: 2px 0; }
.news-item { padding: 9px 13px; border-bottom: 1px solid rgba(29,36,45,.6); transition: background .12s; }
.news-item:hover { background: var(--panel-2); }
.ni-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.ni-src { font-size: 11px; font-weight: 700; color: var(--gold); }
.ni-cat { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .3px; padding: 1px 6px; border: 1px solid var(--line); border-radius: 999px; margin-right: auto; }
.ni-tag { font-size: 10px; font-weight: 800; }
.ni-tag.bull { color: var(--up); }
.ni-tag.bear { color: var(--down); }
.ni-time { font-size: 10.5px; color: var(--dim); font-family: var(--mono); }
.ni-h { font-size: 12.5px; line-height: 1.4; color: var(--txt); }
.news-item { cursor: pointer; }
.ni-top .ni-time { margin-left: auto; }
.news-item.open { background: var(--panel-2); }
.ni-detail { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.ni-detail[hidden] { display: none; }
.ni-detail p { margin: 0 0 8px; font-size: 12px; line-height: 1.55; color: var(--muted); }
.ni-link { font-size: 11.5px; font-weight: 700; color: var(--gold); text-decoration: none; }
.ni-link:hover { text-decoration: underline; }

/* account rows */
.acct-row { display: grid; align-items: center; gap: 8px; padding: 5px 13px; font-size: 12px; }
.acct-row.ord { grid-template-columns: 56px 1fr 1fr 1.1fr; }
.acct-row.bal { grid-template-columns: 1fr 1fr 1fr; }
.acct-row.ord span:nth-child(2), .acct-row.ord span:nth-child(3) { text-align: right; font-family: var(--mono); }
.acct-row.ord span:first-child { font-weight: 700; }
.acct-row.ord span:first-child small { display: block; font-weight: 600; font-size: 9px; color: var(--dim); text-transform: uppercase; letter-spacing: .2px; }
.acct-row.ord .muted { text-align: right; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.acct-row.bal span:nth-child(2), .acct-row.bal span:nth-child(3) { text-align: right; font-family: var(--mono); }
.acct-row.bal b { font-weight: 600; }
.acct-row:hover { background: var(--panel-2); }

/* compact positions inside the narrow account panel */
.acct .pos-row { grid-template-columns: minmax(44px,1.1fr) .65fr 1.2fr .9fr 1fr auto; gap: 6px; padding: 7px 11px; font-size: 11px; }
.acct .pos-row .num small { display: block; font-size: 9px; }
.acct .pos-row .pos-close { padding: 4px 9px; font-size: 10px; }
.acct .pos-row .pos-sym b { font-size: 11.5px; }
.acct .pos-row .pos-sym i { font-size: 9.5px; }

/* economic calendar in the narrow intel panel — all 7 columns incl. Previous(이전), tightened */
.cal-panel .cal-grid-head, .cal-panel .cal-ev {
  grid-template-columns: 40px 44px 32px minmax(0,1fr) 46px 46px 46px;
  gap: 6px; padding-left: 12px; padding-right: 12px;
}
/* Previous(이전) 열을 패널에서 항상 표시 — 중간 폭 반응형 숨김 규칙(.cal-ev .e-val.prev)보다 우선. */
.cal-panel .cal-grid-head span:last-child,
.cal-panel .cal-ev .e-val.prev { display: block; }
.cal-panel .cal-bar { flex-wrap: wrap; row-gap: 6px; padding: 7px 13px; }
.cal-panel .cal-legend { display: none; }
.cal-panel .cal-day { padding-left: 13px; padding-right: 13px; }

/* ── Live derivatives band (Binance public streams: liquidations · funding/OI/long-short · whales) ── */
.grid-live {
  flex: 0 0 auto;
  height: 300px;
  display: grid;
  /* 청산을 포지션 탭으로 옮겨 2칸: 파생 · 고래 */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 9px;
  margin-bottom: 9px;
}
.live { min-height: 0; }
.live .ph { gap: 8px; }
.live .ph h2 { white-space: nowrap; }
.live .ph small { color: var(--gold); font-family: var(--mono); font-size: 11px; }
.live-body { flex: 1; min-height: 0; overflow-y: auto; }

/* shared column headers for liquidation / whale tapes */
.liq-head, .whale-head {
  display: grid; padding: 7px 13px; color: var(--dim); font-size: 10.5px;
  letter-spacing: .3px; text-transform: uppercase; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.liq-head { grid-template-columns: 1fr .8fr 1fr .9fr; }
.whale-head { grid-template-columns: .5fr 1fr 1fr .9fr; }
.liq-head span:nth-child(n+2), .whale-head span:nth-child(n+2) { text-align: right; }

/* liquidation tape rows (long liq = forced sell = down/blue; short liq = forced buy = up/red) */
.liq-row {
  display: grid; grid-template-columns: 1fr .8fr 1fr .9fr; align-items: center;
  padding: 3.5px 13px; font-size: 12px;
}
.liq-row .liq-sym { font-weight: 700; color: var(--txt); }
.liq-row .liq-side, .liq-row .liq-val, .liq-row .liq-t { text-align: right; }
.liq-row .liq-t { color: var(--dim); font-size: 11px; }
.liq-row.long .liq-side, .liq-row.long .liq-val { color: var(--down); }
.liq-row.short .liq-side, .liq-row.short .liq-val { color: var(--up); }
.liq-row.long.mega { background: var(--down-soft); }
.liq-row.short.mega { background: var(--up-soft); }
.liq-row.mega .liq-val { font-weight: 700; }

/* whale-trade rows (buy = up/red, sell = down/blue — matches the trade tape) */
.whale-row {
  display: grid; grid-template-columns: .5fr 1fr 1fr .9fr; align-items: center;
  padding: 3.5px 13px; font-size: 12px;
}
.whale-row .wh-side { font-weight: 700; }
.whale-row .wh-qty, .whale-row .wh-val, .whale-row .wh-t { text-align: right; }
.whale-row .wh-qty { color: var(--muted); }
.whale-row .wh-t { color: var(--dim); font-size: 11px; }
.whale-row.buy .wh-side, .whale-row.buy .wh-val { color: var(--up); }
.whale-row.sell .wh-side, .whale-row.sell .wh-val { color: var(--down); }
.whale-row.buy.mega { background: var(--up-soft); }
.whale-row.sell.mega { background: var(--down-soft); }
.whale-row.mega .wh-val { font-weight: 700; }

/* empty-state hints (liquidations are WS-only; the tape may be quiet or geo-restricted) */
#liq-feed:empty::before { content: attr(data-empty); }
#whale-feed:empty::before { content: attr(data-empty); }
#liq-feed:empty::before, #whale-feed:empty::before {
  display: block; padding: 16px 13px; color: var(--dim); font-size: 11.5px; text-align: center;
}

/* derivatives stats: funding rate · open interest · long/short crowd */
.dv-stats { padding: 4px 0; }
.dv-stat { padding: 11px 14px; border-bottom: 1px solid rgba(29,36,45,.6); }
.dv-stat .dv-k { display: block; color: var(--dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 5px; }
.dv-stat .dv-cd { color: var(--muted); font-family: var(--mono); text-transform: none; letter-spacing: 0; margin-left: 4px; }
.dv-stat .dv-v { font-size: 16px; font-weight: 700; }
.dv-ls .dv-ls-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.dv-ls .dv-ls-top .dv-k { margin-bottom: 0; }
.dv-ls .dv-ls-bar { height: 7px; border-radius: 999px; background: var(--down); overflow: hidden; }
.dv-ls .dv-ls-fill { height: 100%; background: var(--up); transition: width .4s; }
.dv-ls .dv-ls-lbl { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; font-weight: 600; }

/* ── Quant insights band: AI signal · order flow · liquidity · derivatives trend ── */
.grid-insights {
  flex: 0 0 auto;
  height: 240px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.15fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 9px;
  margin-bottom: 9px;
}
.ins { min-height: 0; }
.ins .ph { gap: 8px; }
.ins .ph h2 { white-space: nowrap; }
.ins .ph small { color: var(--gold); font-family: var(--mono); font-size: 11px; }
.ins-sub { padding: 4px 14px 0; color: var(--dim); font-size: 10.5px; }
.ins-body { flex: 1; min-height: 0; padding: 8px 12px 12px; display: flex; flex-direction: column; }
.ins-canvas { width: 100%; height: 100%; display: block; flex: 1; min-height: 0; }
.ins-canvas.sm { height: 56px; flex: 0 0 auto; }
.ins-stat-v { font-family: var(--mono); font-weight: 700; font-size: 13px; }
.up.ins-stat-v, .ins-stat-v.up { color: var(--up); }
.down.ins-stat-v, .ins-stat-v.down { color: var(--down); }
.ins-stat-v.flat { color: var(--muted); }

/* AI signal */
.ai-body { flex-direction: row; gap: 12px; align-items: center; }
.ai-gauge { position: relative; flex: 0 0 auto; width: 132px; height: 100%; display: flex; flex-direction: column; justify-content: center; }
.ai-gauge canvas { width: 132px; height: 84px; display: block; }
.ai-read { text-align: center; margin-top: 2px; }
.sig-label { display: block; font-size: 14px; font-weight: 800; letter-spacing: .4px; }
.sig-score { font-size: 12px; font-weight: 700; }
.sig-label.up, .sig-score.up { color: var(--up); }
.sig-label.down, .sig-score.down { color: var(--down); }
.sig-label.flat, .sig-score.flat { color: var(--muted); }
.ai-factors { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.ins-f { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; }
.ins-fk { font-size: 10.5px; color: var(--muted); }
.ins-fbar { height: 6px; background: var(--panel-3); border-radius: 999px; overflow: hidden; position: relative; }
.ins-ffill { height: 100%; border-radius: 999px; }
.ins-ffill.up { background: var(--up); }
.ins-ffill.down { background: var(--down); }

/* derivatives trend twin mini-charts */
.ins-twin { flex: 1; min-height: 0; padding: 8px 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.ins-mini { display: flex; flex-direction: column; gap: 4px; }
.ins-mini-h { display: flex; justify-content: space-between; align-items: baseline; font-size: 10.5px; color: var(--dim); }

/* market-list AI badge */
.mk-ai { font-style: normal; font-size: 8.5px; font-weight: 800; letter-spacing: .3px; padding: 0 4px; border-radius: 3px; }
.mk-ai.up { color: var(--up); background: var(--up-soft); }
.mk-ai.down { color: var(--down); background: var(--down-soft); }
.mk-ai.flat { color: var(--dim); }

/* ══ Responsive: stack the dense terminal into one scrolling column on narrow viewports
   so the chart always gets usable width (a 4-up grid squeezes the chart to nothing). ══ */
@media (max-width: 1280px) {
  .grid-main {
    height: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
  }
  .grid-main > .side { height: 240px; }
  .grid-main > .chart { height: 380px; }
  .grid-main > .book { height: 470px; }
  /* 체결 내역(tape) — 단일컬럼 스택 시 높이 고정(안 그러면 전체 체결이 끝없이 길어짐). 내부 스크롤. */
  .grid-main > .tape-panel { height: 300px; }
  .form { flex-direction: row; }
  .form > .panel { flex: 1; min-width: 0; }
  .grid-account {
    height: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: 184px 184px;
  }
  .grid-intel {
    height: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 380px 320px 360px;
  }
  .grid-live {
    height: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 320px 320px;
  }
  .grid-insights {
    height: auto;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: 220px 220px;
  }
  /* room is no longer scarce in the wide single column — restore the Previous column */
  .cal-panel .cal-grid-head, .cal-panel .cal-ev {
    grid-template-columns: 62px 78px 52px minmax(0,1fr) 84px 84px 84px;
  }
  .cal-panel .cal-grid-head span:last-child,
  .cal-panel .cal-ev .e-val.prev { display: block; }
  .cal-panel .cal-legend { display: flex; }
}
@media (max-width: 720px) {
  .grid-account { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(3, 184px); }
  .form { flex-direction: column; }
  .cal-panel .cal-grid-head, .cal-panel .cal-ev { grid-template-columns: 50px 56px 42px minmax(0,1fr) 64px 60px; }
  .cal-panel .cal-grid-head span:last-child, .cal-panel .cal-ev .e-val.prev { display: none; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.ph {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px; border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.ph h2 { font-size: 12.5px; font-weight: 700; margin: 0; letter-spacing: .2px; }
.ph .sp { flex: 1; }
.ph .muted { font-size: 11px; }

/* ── Market sidebar ── */
.mkt-search {
  display: flex; align-items: center; gap: 8px;
  margin: 11px 11px 9px; padding: 8px 11px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--muted);
  transition: border-color .15s;
}
.mkt-search:focus-within { border-color: var(--line-2); }
.mkt-search input { flex: 1; background: none; border: none; color: var(--txt); outline: none; min-width: 0; }
.mkt-search input::placeholder { color: var(--dim); }
.mkt-tabs { display: flex; gap: 6px; padding: 0 11px 10px; }
.mkt-tabs button {
  flex: 1; padding: 6px 0; font-size: 12px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--muted); transition: all .15s;
}
.mkt-tabs button:hover { color: var(--txt); }
.mkt-tabs button.on { background: var(--panel-3); color: var(--txt); border-color: var(--line-2); }
.mkt-head, .ob-head, .tape-head, .bt-row, .mkt-row {
  display: grid; align-items: center;
}
.mkt-head {
  grid-template-columns: 1fr auto auto;
  gap: 8px; padding: 7px 13px; color: var(--dim); font-size: 10.5px;
  letter-spacing: .3px; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.mkt-head span:not(:first-child) { text-align: right; }
.mkt-list { overflow-y: auto; flex: 1; }
.mkt-row {
  grid-template-columns: 1fr auto;
  grid-template-areas: "nm px" "nm ch";
  gap: 0 8px; padding: 9px 13px; cursor: pointer;
  border-bottom: 1px solid rgba(29,36,45,.5);
  transition: background .12s;
}
.mkt-row:hover { background: var(--panel-2); }
.mkt-row.on { background: linear-gradient(90deg, var(--gold-soft), transparent 70%); box-shadow: inset 2px 0 0 var(--gold); }
.mkt-row .mk-nm { grid-area: nm; display: flex; flex-direction: column; line-height: 1.25; }
.mkt-row .mk-nm b { font-weight: 600; font-size: 13px; }
.mkt-row .mk-nm small { color: var(--dim); font-size: 11px; font-family: var(--mono); }
.mkt-row .mk-px { grid-area: px; text-align: right; font-size: 12.5px; font-weight: 600; }
.mkt-row .mk-ch { grid-area: ch; text-align: right; font-size: 11px; font-weight: 600; }

/* ── Chart ── */
.chart .ph { justify-content: space-between; }
.tf-tabs, .chart-tools { display: flex; gap: 3px; }
.tf-tabs button {
  padding: 5px 11px; font-size: 12px; font-weight: 600;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--muted); transition: all .15s;
}
.tf-tabs button:hover { color: var(--txt); background: var(--panel-2); }
.tf-tabs button.on { background: var(--panel-3); color: var(--gold); border-color: var(--line-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; font-size: 12px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--muted); transition: all .15s;
}
.chip:hover { color: var(--txt); }
.chip i { width: 7px; height: 7px; border-radius: 2px; background: var(--dim); transition: background .15s; }
.chip.on { color: var(--txt); border-color: var(--line-2); }
.chip.on i { background: var(--gold); box-shadow: 0 0 6px var(--gold-soft); }
#kline { flex: 1; min-height: 0; }

/* ── Order book ── */
.ob-head {
  grid-template-columns: 1fr 1fr;
  padding: 7px 14px; color: var(--dim); font-size: 10.5px;
  letter-spacing: .3px; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.ob-head span:last-child { text-align: right; }
.ob { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.ob-side { flex: 1; overflow-y: auto; }
/* asks: bottom-align so the best ask sits next to the spread (below) while staying scrollable.
   justify-content:flex-end clips the top on overflow and breaks scrolling → solved with margin-top:auto. */
.ob-side.asks { display: flex; flex-direction: column; }
.ob-side.asks > #ob-asks { margin-top: auto; }
.ob-row {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr; align-items: center;
  padding: 2.5px 14px; font-size: 12px; cursor: pointer;
}
.ob-row:hover { background: var(--panel-2); }
.ob-row:hover::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.ob-row .bar { position: absolute; top: 1px; bottom: 1px; right: 0; opacity: .16; border-radius: 2px 0 0 2px; }
.ob-row.ask .bar { background: var(--down); }
.ob-row.bid .bar { background: var(--up); }
.ob-row .p { position: relative; z-index: 1; font-weight: 600; }
.ob-row.ask .p { color: var(--down); }
.ob-row.bid .p { color: var(--up); }
.ob-row .q { position: relative; z-index: 1; text-align: right; color: var(--muted); }
/* a price level where the logged-in user has a resting order — makes the hybrid book visible */
.ob-row.mine { background: var(--gold-soft); }
.ob-row.mine::before {
  content: ""; position: absolute; left: 0; top: 1px; bottom: 1px; width: 2px;
  background: var(--gold); border-radius: 0 2px 2px 0; z-index: 2;
}
.ob-row.mine .p::after {
  content: "MY"; margin-left: 6px; font-size: 8.5px; font-weight: 800;
  color: var(--gold); letter-spacing: .5px; vertical-align: middle;
}
.ob-mid {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.ob-mid .lp { font-size: 18px; font-weight: 800; letter-spacing: -.3px; }
.ob-mid .eq { font-size: 11px; color: var(--muted); }

.strength { padding: 11px 14px; border-top: 1px solid var(--line); flex: 0 0 auto; }
.strength .top { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 12px; }
.strength .top .muted { text-transform: uppercase; letter-spacing: .3px; font-size: 11px; }
.strength .sbar { height: 7px; border-radius: 999px; background: var(--down); overflow: hidden; }
.strength .sbar .b { height: 100%; background: var(--up); transition: width .3s; }
.strength .lbl { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; font-weight: 600; }
.strength .lbl .u { color: var(--up); }
.strength .lbl .d { color: var(--down); }
.strength .s-spark { display: block; width: 100%; height: 40px; margin-top: 9px; }

/* ── Order form ── */
.bs-tabs { display: flex; flex: 0 0 auto; gap: 8px; padding: 11px 13px 3px; }
.bs-tabs button {
  flex: 1; padding: 11px 0; font-size: 14px; font-weight: 700;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--muted); transition: all .15s; cursor: pointer;
}
.bs-tabs button:hover { color: var(--txt); border-color: var(--line-2); }
.bs-tabs .buy.on { color: #fff; background: var(--up); border-color: var(--up); box-shadow: 0 2px 10px var(--up-soft); }
.bs-tabs .sell.on { color: #fff; background: var(--down); border-color: var(--down); box-shadow: 0 2px 10px var(--down-soft); }
.form-body { padding: 11px 13px; display: flex; flex-direction: column; gap: 7px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.login-row { display: flex; gap: 7px; }
.login-row input {
  flex: 1; padding: 9px 11px; background: var(--panel-2); min-width: 0;
  border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--txt); outline: none;
  transition: border-color .15s;
}
.login-row input:focus { border-color: var(--line-2); }
.login-row button {
  flex: 1; padding: 10px 13px; background: var(--gold-soft); border: 1px solid var(--gold);
  border-radius: var(--radius-sm); color: var(--gold); white-space: nowrap; font-weight: 700;
  cursor: pointer; transition: background .15s, filter .15s;
}
.login-row button:hover { filter: brightness(1.15); }
.login-row button.active {
  background: var(--panel-3); border-color: var(--line-2); color: var(--muted); font-weight: 600;
}
.avail {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted);
  padding: 8px 11px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.avail .albl { color: var(--dim); }   /* 라벨은 JS 가 i18n 으로 렌더(중복 방지로 ::before 제거) */
.avail b { color: var(--txt); font-family: var(--mono); font-weight: 700; }
.field {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; transition: border-color .15s;
}
.field:focus-within { border-color: var(--line-2); }
.field label { color: var(--dim); font-size: 12px; width: 32px; flex: 0 0 auto; }
.field input {
  flex: 1; background: none; border: none; color: var(--txt); outline: none;
  text-align: right; font-family: var(--mono); font-size: 14px; font-weight: 600; min-width: 0;
}
.field .unit { color: var(--muted); font-size: 12px; }
.field .step-btn {
  flex: 0 0 auto; width: 25px; height: 25px; line-height: 1; font-size: 16px; font-weight: 700;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); display: flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.field .step-btn:hover { color: var(--txt); border-color: var(--line-2); background: var(--panel-3); }
.field .step-btn:active { background: var(--line); }
.pct { display: flex; gap: 6px; }
.pct button {
  flex: 1; padding: 7px 0; font-size: 12px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--muted); transition: all .12s;
}
.pct button:hover { color: var(--txt); border-color: var(--line-2); background: var(--panel-3); }
.pct button:active { transform: translateY(1px); }
.submit {
  margin-top: 5px; padding: 13px 0; font-size: 15px; font-weight: 800;
  border: none; border-radius: var(--radius-sm); color: #fff; letter-spacing: .5px;
  transition: filter .15s, transform .05s;
}
.submit:hover { filter: brightness(1.08); }
.submit:active { transform: translateY(1px); }
.submit.buy { background: var(--up); }
.submit.sell { background: var(--down); }
/* 주문폼 하단 고정 매수/매도 — form-body 가 스크롤돼도 이 버튼은 항상 패널 맨 아래에 보인다. */
.form > .panel > .submit { flex: 0 0 auto; margin: 0; border-radius: 0; border-top: 1px solid rgba(255,255,255,.07); }

/* ── Icons (self-hosted Lucide sprite) — monochrome line icons replacing emoji ── */
.ic {
  width: 1em; height: 1em; display: inline-block; vertical-align: -0.14em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  overflow: visible;
}
.ph h2 .ic { width: 15px; height: 15px; vertical-align: -2.5px; color: var(--gold); margin-right: 2px; }
.foot-legal .ic { width: 13px; height: 13px; vertical-align: -2px; color: var(--gold); opacity: .85; }
.lev-badge .ic { width: 11px; height: 11px; vertical-align: -1px; }
.next-econ .ic, .k .ic { width: 12px; height: 12px; vertical-align: -2px; color: var(--gold); }

/* ── Info tooltip (hover) — "what is this panel?" popup on panel headers ── */
.ph { position: relative; }
.ph h2[data-tip] { cursor: help; }
.ph h2[data-tip]::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  width: max-content; max-width: 230px; white-space: normal; text-align: left;
  padding: 8px 11px; border-radius: 9px;
  background: #141b25; color: var(--txt); border: 1px solid var(--line-2);
  box-shadow: 0 12px 30px rgba(0,0,0,.55);
  font-size: 11.5px; font-weight: 500; line-height: 1.5; letter-spacing: 0;
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity .14s ease, transform .14s ease;
}
.ph h2[data-tip]::before {
  content: ''; position: absolute; top: calc(100% + 2px); left: 13px; z-index: 61;
  border: 6px solid transparent; border-bottom-color: #141b25;
  opacity: 0; transition: opacity .14s ease; pointer-events: none;
}
.ph h2[data-tip]:hover::after, .ph h2[data-tip]:focus-visible::after { opacity: 1; transform: translateY(0); }
.ph h2[data-tip]:hover::before, .ph h2[data-tip]:focus-visible::before { opacity: 1; }

/* ── Trade tape ── */
.tape-panel { flex: 1; min-height: 0; }
.tape-head {
  display: grid; grid-template-columns: 1.2fr 1fr .8fr;
  padding: 7px 13px; color: var(--dim); font-size: 10.5px;
  letter-spacing: .3px; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.tape-head span:nth-child(2) { text-align: right; }
.tape-head span:last-child { text-align: right; }
.tape { flex: 1; overflow-y: auto; }
.tp-row {
  display: grid; grid-template-columns: 1.2fr 1fr .8fr;
  padding: 2.5px 13px; font-size: 12px;
}
.tp-row .p { font-weight: 600; }
.tp-row.buy .p { color: var(--up); }
.tp-row.sell .p { color: var(--down); }
.tp-row .q { text-align: right; color: var(--muted); }
.tp-row .t { text-align: right; color: var(--dim); font-size: 11px; }

/* ── Bottom: open orders / fills / assets ── */
.bt-tabs { display: flex; gap: 4px; padding: 9px 11px; }
.bt-tabs button {
  padding: 7px 13px; font-size: 12px; font-weight: 600;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--muted); transition: all .15s;
}
.bt-tabs button:hover { color: var(--txt); }
.bt-tabs button.on { background: var(--panel-3); color: var(--txt); border-color: var(--line-2); }
.bt-tabs .cnt {
  margin-left: 5px; padding: 0 6px; font-size: 11px; font-weight: 700;
  background: var(--line-2); border-radius: 999px; color: var(--txt);
}
.bt-tabs button.on .cnt { background: var(--gold-soft); color: var(--gold); }
.bt-body { flex: 1; overflow-y: auto; padding: 4px 0; }
.bt-row {
  grid-template-columns: 80px 1fr 1fr 2fr;
  gap: 8px; padding: 6px 14px; font-size: 12px;
}
.bt-row span:nth-child(2), .bt-row span:nth-child(3) { text-align: right; font-family: var(--mono); }
.bt-row span:first-child { font-weight: 700; }
.bt-row .muted { text-align: right; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.bt-empty { padding: 30px 22px; text-align: center; color: var(--dim); font-size: 12px; }

/* ── Paper futures: trade-mode toggle / leverage / preview / positions ── */
.trade-mode { display: flex; gap: 6px; padding: 9px 11px 0; flex: 0 0 auto; }
.trade-mode button {
  flex: 1; padding: 7px 0; font-size: 12px; font-weight: 700;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--muted); transition: color .15s, background .15s, border-color .15s;
}
.trade-mode button:hover { color: var(--txt); }
.trade-mode button.on { background: var(--panel-3); color: var(--gold); border-color: var(--line-2); }
.trade-mode .lev-badge { font-size: 11px; }

/* Spot order-type toggle (Limit / Market) */
.order-type { display: flex; gap: 6px; }
.order-type[hidden] { display: none; }
.order-type button {
  flex: 1; padding: 6px 0; font-size: 12px; font-weight: 700;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--muted); transition: color .15s, background .15s, border-color .15s;
}
.order-type button:hover { color: var(--txt); }
.order-type button.on { background: var(--panel-3); color: var(--txt); border-color: var(--line-2); }

.lev-row { display: flex; flex-direction: column; gap: 7px; }
.lev-row[hidden] { display: none; }
.lev-head { display: flex; justify-content: space-between; align-items: baseline; color: var(--dim); font-size: 12px; }
.lev-head b { color: var(--gold); font-family: var(--mono); font-size: 13px; font-weight: 800; }
.lev-opts { display: flex; flex-wrap: wrap; gap: 5px; }
.lev-opts button {
  flex: 1 0 auto; min-width: 40px; padding: 5px 0; font-size: 11px; font-weight: 700;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; color: var(--muted);
}
.lev-opts button:hover { color: var(--txt); border-color: var(--line-2); }
.lev-opts button.on { background: var(--gold-soft); color: var(--gold); border-color: rgba(232,179,57,.4); }

.fut-info {
  display: flex; flex-direction: column; gap: 4px; padding: 8px 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.fut-info[hidden] { display: none; }
.fi-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; color: var(--muted); }
.fi-row b { color: var(--txt); font-family: var(--mono); font-weight: 700; }
.fi-row.muted { color: var(--dim); font-size: 11px; }

.pos-row {
  display: grid; align-items: center;
  grid-template-columns: 1.5fr .8fr 1.4fr 1fr 1.3fr auto;
  gap: 8px; padding: 8px 13px; border-bottom: 1px solid var(--line); font-size: 12px;
}
.pos-row > span:not(.pos-sym) { text-align: right; font-family: var(--mono); white-space: nowrap; }
.pos-row small { font-size: 10px; }
.pos-sym { display: flex; flex-direction: column; line-height: 1.3; }
.pos-sym b { font-weight: 700; font-size: 12.5px; }
.pos-sym i { font-style: normal; font-size: 10.5px; font-weight: 700; }
.pos-close {
  padding: 4px 11px; font-size: 11px; font-weight: 700; justify-self: end;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; color: var(--txt);
}
.pos-close:hover { background: var(--down-soft); color: var(--down); border-color: var(--down); }

/* ════════════════════════════════════════════════════════
   Economic calendar (custom)
   ════════════════════════════════════════════════════════ */
/* ── Economy & news slide-up drawer ── */
.info-fab {
  position: fixed; left: 14px; bottom: 14px; z-index: 9999;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 15px; border-radius: 999px;
  background: rgba(20, 22, 28, .94); border: 1px solid var(--line-2);
  color: var(--txt); font-size: 12px; font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .45);
  transition: border-color .15s, color .15s;
}
.info-fab:hover { border-color: var(--gold); color: var(--gold); }
.info-fab .caret { font-size: 9px; transition: transform .3s; }
.info-fab[aria-expanded="true"] .caret { transform: rotate(180deg); }

.info-scrim {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(0, 0, 0, .5); opacity: 0; pointer-events: none;
  transition: opacity .3s ease;
}
.info-scrim.open { opacity: 1; pointer-events: auto; }

.info-drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10000;
  margin: 0 auto; width: min(980px, 96vw); height: min(74vh, 660px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -14px 48px rgba(0, 0, 0, .6);
  transform: translateY(108%);
  transition: transform .34s cubic-bezier(.22, .61, .36, 1);
}
.info-drawer.open { transform: translateY(0); }
.info-head {
  display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
  padding: 9px 12px; border-bottom: 1px solid var(--line);
}
.info-tabs { display: flex; gap: 5px; flex: 1; }
.info-tabs button {
  padding: 6px 16px; font-size: 13px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.info-tabs button.on { background: #1f2630; color: var(--txt); border-color: var(--line-2); }
.info-close {
  width: 32px; height: 32px; border-radius: 8px; font-size: 14px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.info-close:hover { color: var(--txt); border-color: var(--line-2); }
.info-body { flex: 1; min-height: 0; position: relative; }
.info-pane { position: absolute; inset: 0; display: flex; flex-direction: column; }
.info-pane[hidden] { display: none; }
.info-pane .tradingview-widget-container,
.info-pane iframe { height: 100% !important; width: 100% !important; border: 0; }
.news-tabs {
  display: flex; gap: 5px; flex: 0 0 auto;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.news-tabs button {
  padding: 5px 13px; font-size: 12px; border-radius: 7px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.news-tabs button.on { background: #1f2630; color: var(--txt); border-color: var(--line-2); }
.news-feed { flex: 1; min-height: 0; }

/* ── AI 단기 전망 패인 ── */
#info-forecast { padding: 0; }
.fc-head {
  display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.fc-title { font-size: 13px; font-weight: 700; }
.fc-title small { color: var(--muted); font-family: var(--mono); font-weight: 600; margin-left: 4px; }
.fc-refresh {
  margin-left: auto; padding: 6px 16px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 700;
  background: var(--gold-soft); color: var(--gold); border: 1px solid rgba(232,179,57,.35);
}
.fc-refresh:hover { background: rgba(232,179,57,.22); }
.fc-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; }
.fc-loading, .fc-error { color: var(--muted); font-size: 13px; padding: 24px; text-align: center; }
.fc-error { color: var(--up); }
.fc-error small { display: block; margin-top: 6px; color: var(--dim); font-size: 11px; }
.fc-card { display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.fc-top { display: flex; align-items: center; gap: 12px; }
.fc-badge {
  padding: 5px 14px; border-radius: 999px; font-size: 14px; font-weight: 800;
}
.fc-badge.up { background: var(--up-soft); color: var(--up); }
.fc-badge.down { background: var(--down-soft); color: var(--down); }
.fc-badge.flat { background: var(--panel-3); color: var(--muted); }
.fc-conf { font-size: 13px; color: var(--muted); }
.fc-conf b { color: var(--txt); font-family: var(--mono); }
.fc-horizon { margin-left: auto; font-size: 12px; color: var(--dim); font-family: var(--mono); }
.fc-summary { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--txt); }
.fc-drivers { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.fc-drivers li { font-size: 13px; line-height: 1.5; color: var(--txt); }
.fc-meta { font-size: 11px; color: var(--dim); font-family: var(--mono); }
.fc-disc { font-size: 11px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 10px; }
.fc-fng { font-size: 11.5px; color: var(--gold); font-weight: 600; }
.fc-levels { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
.fc-lvrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fc-lvk { font-size: 11px; color: var(--dim); width: 74px; }
.fc-lv { padding: 2px 9px; border-radius: 6px; font-size: 12px; font-family: var(--mono); border: 1px solid var(--line); }
.fc-lv.res { color: var(--up); background: var(--up-soft); }
.fc-lv.sup { color: var(--down); background: var(--down-soft); }
.fc-inval { font-size: 12px; color: var(--gold); }
.fc-scen { display: flex; flex-direction: column; gap: 5px; padding-top: 4px; }
.fc-scen-h { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .3px; }
.fc-scen-i { font-size: 12.5px; line-height: 1.5; color: var(--txt); padding-left: 8px; border-left: 2px solid var(--line-2); }

.cal-bar {
  display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
  padding: 8px 14px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.cal-bar .cal-nav { display: flex; align-items: center; gap: 2px; }
.cal-bar .cal-nav button {
  width: 26px; height: 26px; display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); font-size: 13px; transition: all .12s;
}
.cal-bar .cal-nav button:hover { color: var(--txt); border-color: var(--line-2); }
.cal-bar .cal-today {
  font-size: 13px; font-weight: 700; padding: 0 6px; white-space: nowrap;
}
.cal-bar .cal-today small { color: var(--dim); font-weight: 500; margin-left: 6px; font-size: 11px; }
.cal-bar .sp { flex: 1; }
.cal-legend { display: flex; align-items: center; gap: 13px; color: var(--dim); font-size: 11px; }
.cal-legend span { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.cal-imp { display: inline-flex; gap: 2px; align-items: center; }
.cal-imp i { width: 4px; border-radius: 1px; background: var(--dim); }
.cal-imp i.h1 { height: 6px; } .cal-imp i.h2 { height: 9px; } .cal-imp i.h3 { height: 12px; }
.cal-imp.lv3 i { background: var(--up); }
.cal-imp.lv2 i:nth-child(-n+2) { background: var(--gold); }
.cal-imp.lv1 i:nth-child(1) { background: var(--muted); }

.cal-filters { display: flex; gap: 6px; }
.cal-filters button {
  padding: 5px 11px; font-size: 11.5px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); transition: all .13s; white-space: nowrap;
}
.cal-filters button:hover { color: var(--txt); border-color: var(--line-2); }
.cal-filters button.on { background: var(--gold-soft); color: var(--gold); border-color: rgba(232,179,57,.4); }

.cal-scroll { flex: 1; overflow-y: auto; }

.cal-grid-head, .cal-ev {
  display: grid;
  grid-template-columns: 62px 78px 52px minmax(0,1fr) 84px 84px 84px;
  align-items: center; gap: 10px;
}
.cal-grid-head {
  position: sticky; top: 0; z-index: 2;
  padding: 7px 16px; font-size: 10.5px; letter-spacing: .3px; text-transform: uppercase;
  color: var(--dim); background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.cal-grid-head span:nth-child(n+5) { text-align: right; }

.cal-day {
  position: sticky; top: 30px; z-index: 1;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 16px;
  background: linear-gradient(90deg, var(--panel-2), var(--panel) 80%);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.cal-day .d-date { font-size: 12.5px; font-weight: 800; letter-spacing: .2px; }
.cal-day .d-date.is-today { color: var(--gold); }
.cal-day .d-dow { font-size: 11px; color: var(--dim); }
.cal-day .d-badge {
  margin-left: auto; font-size: 10.5px; color: var(--muted); white-space: nowrap;
  padding: 2px 9px; background: var(--panel-3); border: 1px solid var(--line); border-radius: 999px;
}
.cal-day .d-badge b { color: var(--up); font-weight: 800; }

.cal-ev {
  padding: 7.5px 16px; font-size: 12px;
  border-bottom: 1px solid rgba(29,36,45,.5);
  transition: background .12s;
}
.cal-ev:hover { background: var(--panel-2); }
.cal-ev.next { background: linear-gradient(90deg, var(--gold-soft), transparent 60%); box-shadow: inset 2px 0 0 var(--gold); }
/* Released events read as faded — but keep the country flag at full opacity so it stays crisp. */
.cal-ev.done > *:not(.cal-flag) { opacity: .62; }

.cal-ev .e-time { font-family: var(--mono); font-weight: 700; font-size: 12.5px; color: var(--txt); }
.cal-ev .e-time small { display: block; color: var(--dim); font-size: 9.5px; font-weight: 500; letter-spacing: .3px; }
.cal-ev .e-time.live { color: var(--up); }

.cal-flag {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.cal-flag .fc {
  width: 22px; height: 16px; border-radius: 3px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 8.5px; font-weight: 800; letter-spacing: .2px;
  color: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25) inset;
  background-size: cover;
}
.cal-flag .fimg {
  width: 22px; height: 16px; border-radius: 3px; flex: 0 0 auto; object-fit: cover;
  display: block; box-shadow: 0 0 0 1px rgba(255,255,255,.14);   /* crisp outer ring (no inset dimming) */
}
.cal-flag .ccode {
  font: 700 10px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .4px;
  color: var(--muted); padding: 3px 5px; border-radius: 4px;
  border: 1px solid rgba(255,255,255,.10); background: rgba(255,255,255,.03);
}
.cal-empty { padding: 26px 12px; text-align: center; color: var(--muted); font-size: 12px; }
.cal-nav button[disabled] { opacity: .3; cursor: default; }

.cal-ev .e-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.cal-ev .e-name b { font-weight: 600; color: var(--txt); }
.cal-ev .e-name .e-rev { color: var(--dim); font-size: 11px; margin-left: 6px; }

.cal-ev .e-val { text-align: right; font-family: var(--mono); font-size: 12.5px; }
.cal-ev .e-val.actual { font-weight: 800; }
.cal-ev .e-val.actual.beat { color: var(--up); }
.cal-ev .e-val.actual.miss { color: var(--down); }
.cal-ev .e-val.actual.wait { color: var(--dim); font-weight: 600; font-size: 10px; font-family: -apple-system, sans-serif; white-space: nowrap; }
.cal-ev .e-val.fc, .cal-ev .e-val.prev { color: var(--muted); }
.cal-ev .e-val small { display: block; color: var(--dim); font-size: 9.5px; text-transform: uppercase; letter-spacing: .3px; font-family: -apple-system, sans-serif; margin-bottom: 1px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #232b35; border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #2e3742; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Toast ── */
#toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: var(--panel-3); border: 1px solid var(--line-2); color: var(--txt);
  padding: 11px 20px; border-radius: 10px; font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,.7);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive: stack on narrow screens ── */
@media (max-width: 1320px) {
  .ticker .stat.opt { display: none; }
}
@media (max-width: 1180px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 14px; }
  .ticker { flex-wrap: wrap; gap: 0; }
  .conn { border-left: none; }
  .grid {
    grid-template-columns: minmax(0, 1fr) 304px;
    grid-template-rows: auto 360px auto 302px;
    grid-template-areas:
      "side   side"
      "chart  book"
      "form   form"
      "bottom bottom";
  }
  .form { flex-direction: row; }
  .form > .panel { flex: 1; }
}
@media (max-width: 760px) {
  /* Header: drop the price + 24h stats onto their own full-width row so the brand's
     SIM badge / connection chip can't overlap or bury the price. */
  .topbar { align-items: center; row-gap: 8px; }
  .sim-badge { font-size: 9px; padding: 2px 7px; }
  .ticker { order: 10; flex-basis: 100%; width: 100%; gap: 0; overflow-x: auto; flex-wrap: nowrap; }
  .ticker .big { padding-left: 0; padding-right: 16px; }
  .ticker .big .price { font-size: 20px; }
  .conn { margin-left: auto; border-left: none; padding-right: 0; }
  .cal-grid-head, .cal-ev { grid-template-columns: 52px 60px 40px minmax(0,1fr) 64px 64px; }
  .cal-ev .e-val.prev, .cal-grid-head span:last-child { display: none; }
  .grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 320px 280px auto auto;
    grid-template-areas: "side" "chart" "book" "form" "bottom";
  }
  .form { flex-direction: column; }
  /* Order form sizes to its content — no empty gap below the Buy/Sell button.
     (Placed in this last media block so it wins over the 1180px `.form > .panel { flex:1 }`.) */
  .form > .panel { flex: 0 0 auto; }
  .form-body { overflow-y: visible; }
  /* Trades (체결 내역) capped so the list doesn't run very long; it scrolls within. (tape 는 이제 grid-main 직속) */
  .grid-main > .tape-panel { height: 240px; }
}
