.market-categories {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #091416;
}

.market-categories button {
  min-width: 0;
  border: 1px solid #1b2d31;
  background: #0b191c;
  border-radius: 7px;
  padding: 12px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: .18s;
}

.market-categories button:hover { border-color: #31504f; background: #0d2022; }
.market-categories button.active { border-color: #168b72; background: #0c2924; box-shadow: inset 0 0 0 1px #12d8a022; }
.market-categories .category-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #16312e; color: var(--green); font-weight: 800; }
.market-categories .category-icon.gold { background: #3a3017; color: #ffd65a; }
.market-categories .category-icon.oil { background: #20292c; color: #b9c6c8; }
.market-categories .category-icon.stock { background: #153b58; color: #7fc8ff; }
.market-categories b, .market-categories small { display: block; }
.market-categories b { font-size: 12px; }
.market-categories small { margin-top: 3px; color: #617579; font-size: 8px; }
.market-categories em { font-style: normal; color: #74888a; font-size: 9px; }
.market-categories button.active em { color: var(--green); }

.trade-categories { min-height: 48px; padding: 7px 15px; display: flex; align-items: center; gap: 7px; border-bottom: 1px solid var(--line); background: #091416; }
.trade-categories button { min-width: 105px; height: 34px; padding: 0 12px; display: flex; align-items: center; gap: 8px; border: 1px solid #1b2d31; border-radius: 5px; background: #0b191c; color: #718386; font-size: 10px; font-weight: 700; cursor: pointer; }
.trade-categories button span { color: var(--green); font-weight: 800; }
.trade-categories button em { margin-left: auto; color: #53686b; font-size: 8px; font-style: normal; }
.trade-categories button:hover { border-color: #31504f; color: var(--text); }
.trade-categories button.active { border-color: #168b72; background: #0c2924; color: #fff; }
.trade-categories button.active em { color: var(--green); }

@media (max-width: 900px) {
  .market-categories { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 620px) {
  .market-categories { grid-template-columns: repeat(2, 1fr); padding: 12px; gap: 7px; }
  .market-categories button { padding: 9px; grid-template-columns: 30px 1fr auto; }
  .market-categories .category-icon { width: 30px; height: 30px; }
  .market-categories button:last-child { grid-column: 1 / -1; }
  .market-table th:nth-child(6), .market-table td:nth-child(6) { display: none; }
  .market-table .asset { gap: 7px; }
  .market-table .asset-icon { width: 27px; height: 27px; font-size: 9px; }
  .market-table td:first-child { min-width: 150px; }
  .trade-page { padding-inline: 0; }
  .trade-categories { padding: 7px 8px; gap: 5px; overflow-x: auto; scrollbar-width: none; }
  .trade-categories::-webkit-scrollbar { display: none; }
  .trade-categories button { min-width: auto; flex: 1 0 auto; height: 32px; padding: 0 9px; }
  .ticker-head { height: auto; min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px 8px; padding: 10px 12px; overflow: visible; }
  .ticker-head .pair { grid-column: 1 / -1; min-width: 0; }
  .pair-select { margin-left: auto; width: min(52vw, 220px); }
  .ticker-main strong { font-size: 17px; }
  .ticker-stat { min-width: 0; }
  .ticker-head .ticker-stat:nth-of-type(4) { display: none; }
  .trade-source { position: static; grid-column: 1 / -1; justify-self: start; padding: 5px 8px; }
  /* 모바일에서는 세로 한 줄로 쌓되, 주문 폼을 차트 바로 아래로 올려 스크롤을 줄인다.
     호가창은 데모용 표시라 아래로 내리고 높이를 줄인다(주문까지 도달 거리 최소화). */
  .trade-grid { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .chart-panel { order: 1; height: 300px; }
  .order-panel { order: 2; height: auto; min-height: 0; padding: 12px 14px 20px; }
  .panel-tabs { overflow-x: auto; gap: 10px; }
  .intervals { flex-shrink: 0; }
  .orderbook { order: 3; height: auto; max-height: 230px; overflow: auto; }
  .open-orders { order: 4; min-height: 0; height: auto; max-height: 230px; overflow: auto; }
}
