@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');
@font-face { font-family:'Pulse'; src:url('/fonts/pulse-regular.ttf')  format('truetype'); font-weight:400; font-display:swap; }
@font-face { font-family:'Pulse'; src:url('/fonts/pulse-medium.ttf')   format('truetype'); font-weight:500; font-display:swap; }
@font-face { font-family:'Pulse'; src:url('/fonts/pulse-semibold.ttf') format('truetype'); font-weight:600; font-display:swap; }
@font-face { font-family:'Pulse'; src:url('/fonts/pulse-bold.ttf')     format('truetype'); font-weight:700; font-display:swap; }
.mk-num, .mk-price, .mk-idx-price, .mk-chg { font-family:'Pulse','Manrope',-apple-system,sans-serif; font-variant-numeric: tabular-nums; font-feature-settings:'tnum' 1,'lnum' 1; }

:root {
  --mk-bg: #0d0f14;
  --mk-panel: #0d0f14;
  --mk-line: rgba(201, 220, 255, 0.08);
  --mk-text: #f4f8ff;
  --mk-muted: #95a3bc;
  --mk-brand: #00f5ff;
  --mk-green: #00b7d4;
  --mk-red: #ff3377;
  --mk-header-bg: #0d0f14;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
}

body.markets-page {
  min-height: 100vh;
  font-family: 'Pulse', 'Manrope', sans-serif;
  background: #0d0f14;
  color: #f4f8ff;
}

body.markets-nav-open { overflow: hidden; }

/* ── Header ── */
.mk-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: #0d0f14;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  width: 100%;
  overflow: hidden;
}

.mk-header-inner {
  width: 100%;
  max-width: 100%;
  padding: 0 1rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.mk-brand {
  display: flex;
  align-items: center;
  gap: 0.62rem;
  text-decoration: none;
  flex-shrink: 0;
}

.mk-brand-logo {
  width: 34px;
  height: 34px;
  padding: 2px;
  display: block;
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(8, 18, 28, 0.96), rgba(3, 8, 16, 0.96));
  object-fit: contain;
  flex: 0 0 auto;
  box-shadow:
    inset 0 0 0 1px rgba(87, 206, 255, 0.18),
    0 0 16px rgba(45, 214, 255, 0.16),
    0 8px 18px rgba(0, 0, 0, 0.3);
}

.mk-brand-mark {
  width: 26px;
  height: 26px;
  background: var(--mk-brand);
  border-radius: 6px;
  display: inline-block;
}

.mk-brand-word {
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--mk-brand);
}

.mk-nav {
  display: flex;
  gap: 1.5rem;
  flex: 1;
}

.mk-nav a {
  color: var(--mk-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s;
  white-space: nowrap;
}

.mk-nav a:hover,
.mk-nav a.active {
  color: var(--mk-text);
}

.mk-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

.mk-login {
  color: var(--mk-brand);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.4rem 0.9rem;
  border: 1.5px solid rgba(0,245,255,0.35);
  border-radius: 8px;
  transition: border-color 0.2s;
  white-space: nowrap;
}

.mk-login:hover { border-color: var(--mk-brand); }

.mk-signup {
  background: var(--mk-brand);
  color: #000;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.42rem 1.1rem;
  border-radius: 8px;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.mk-signup:hover { opacity: 0.85; }

.mk-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
}

.mk-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--mk-text);
  border-radius: 2px;
}

/* ── Mobile drawer ── */
.mk-nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
}

.mk-nav-overlay.hidden { display: none; }

.mk-nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(320px, 85vw);
  height: 100%;
  background: #111;
  z-index: 400;
  transform: translateX(100%);
  transition: transform 0.28s ease;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--mk-line);
}

.mk-nav-drawer.is-open { transform: translateX(0); }

.mk-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--mk-line);
  font-weight: 700;
  font-size: 1rem;
}

.mk-nav-head strong {
  display: inline-flex;
  align-items: center;
  gap: 0.58rem;
}

.mk-nav-head button {
  background: none;
  border: none;
  color: var(--mk-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem;
}

.mk-nav-links {
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  gap: 0;
}

.mk-nav-links a {
  color: var(--mk-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.75rem 1.25rem;
  border-bottom: none;
  transition: background 0.15s;
}

.mk-nav-links a:hover { background: rgba(255,255,255,0.04); }

/* ── Ticker bar ── */
.mk-ticker-bar {
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--mk-line);
  padding: 0.4rem 0;
  font-size: 0.74rem;
}

.mk-ticker-track {
  display: flex;
  gap: 2.5rem;
  width: max-content;
  animation: mk-ticker 35s linear infinite;
}

.mk-ticker-item {
  display: flex;
  gap: 0.4rem;
  white-space: nowrap;
  color: var(--mk-muted);
}

.mk-ticker-item strong { color: var(--mk-text); }
.mk-ticker-item em { font-style: normal; }
.mk-ticker-item.up em { color: var(--mk-green); }
.mk-ticker-item.dn em { color: var(--mk-red); }

@keyframes mk-ticker {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ── Main ── */
.mk-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.2rem 0 6rem;
}

@media (min-width: 769px) {
  .mk-main { padding: 2.5rem 1.5rem 6rem; }
}

/* ── Tabs ── */
.mk-tabs-center {
  margin-bottom: 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.mk-tabs {
  display: flex;
  width: 100%;
  border-bottom: none;
  padding: 0 0.85rem;
  gap: 0;
}

.mk-tabs button {
  flex: 0 0 auto;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #6b7a99;
  font-family: 'Pulse', 'Manrope', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.75rem 1.2rem 0.65rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  margin-bottom: -1px;
}

.mk-tabs button.active {
  color: #00f5ff;
  border-bottom: 2px solid #00f5ff;
  background: none;
  border-radius: 0;
  padding: 0.75rem 1.2rem 0.65rem;
}

.mk-tabs button:not(.active):hover { color: #f4f8ff; }

/* ── Controls row ── */
.mk-controls-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.mk-search-row {
  padding: 0.7rem 0.85rem 0.15rem;
}

.mk-search-wrap {
  position: relative;
  width: 100%;
}

.mk-search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--mk-muted);
  font-size: 1rem;
  pointer-events: none;
  display: flex;
}

.mk-search-wrap input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid transparent;
  border-radius: 20px;
  color: var(--mk-text);
  font-family: 'Pulse', 'Manrope', sans-serif;
  font-size: 0.85rem;
  padding: 0.6rem 0.9rem 0.6rem 2.5rem;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.mk-search-wrap input::placeholder { color: var(--mk-muted); }
.mk-search-wrap input:focus { border-color: rgba(0, 245, 255, 0.35); background: rgba(255,255,255,0.09); }

.mk-total-count {
  margin-left: auto;
  color: var(--mk-muted);
  font-size: 0.72rem;
  align-self: center;
  padding-right: 0.85rem;
  white-space: nowrap;
}

@media (min-width: 769px) {
  .mk-search-row { padding: 0 0 0.9rem; }
  .mk-search-wrap { max-width: 320px; }
}

/* ── Table wrap ── */
.mk-table-wrap {
  border-radius: 14px;
  overflow: hidden;
  background: #0d0f14;
  border: none;
}

.mk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: #0d0f14;
  table-layout: auto;
}

/* Table header */
.mk-table thead {
  background: #0d0f14;
}

.mk-table thead th {
  background: #0d0f14;
  color: #6b7a99;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.75rem 1.4rem;
  text-align: left;
  border: none;
  border-bottom: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

.mk-table thead th:hover { color: #f4f8ff; }
.mk-table thead th.sort-asc,
.mk-table thead th.sort-desc { color: var(--mk-text); }

.mk-table thead th:nth-child(2),
.mk-table thead th:nth-child(3),
.mk-table thead th:nth-child(4) { text-align: right; }

.mk-table thead th.sort-asc .mk-sort-caret,
.mk-table thead th.sort-desc .mk-sort-caret { display: none; }
.mk-table thead th.sort-asc::after { content: ' ↑'; color: var(--mk-brand); }
.mk-table thead th.sort-desc::after { content: ' ↓'; color: var(--mk-brand); }

/* Table rows */
.mk-table tbody tr {
  background: #0d0f14;
  border-bottom: none;
  transition: background 0.15s;
}

.mk-table tbody tr:last-child { border-bottom: none; }
.mk-table tbody tr:hover { background: #0d0d0d; }

.mk-table tbody td {
  background: transparent;
  padding: 1rem 1.4rem;
  vertical-align: middle;
  color: #f4f8ff;
  border: none;
}

.mk-table tbody td:nth-child(2),
.mk-table tbody td:nth-child(3),
.mk-table tbody td:nth-child(4) { text-align: right; }

/* Coin cell */
.mk-coin-cell {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.mk-coin-ico {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(0, 184, 151,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.mk-coin-ico img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  position: absolute;
  inset: 0;
}

.mk-coin-fb {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--mk-brand);
  z-index: 1;
}

.mk-coin-names {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.mk-coin-sym-row {
  display: flex;
  align-items: center;
  min-width: 0;
}

.mk-coin-sym {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--mk-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  min-width: 0;
  flex-shrink: 1;
}

.mk-coin-name {
  font-size: 0.73rem;
  color: var(--mk-muted);
}

/* "Perpetual" badge shown on symbol rows when the Futures segment is active —
   matches Bitget's futures market list (small outlined chip next to the pair). */
.mk-perp-badge {
  display: inline-block;
  flex-shrink: 0;
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 5px;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--mk-muted);
  vertical-align: middle;
  white-space: nowrap;
}

/* Futures view: "BTCUSDT [Perpetual]" needs more room than the plain "BTC / USDT"
   spot row, so borrow a little width from the price/change columns. */
@media (max-width: 640px) {
  body.mk-futures-view .mk-table th:nth-child(1),
  body.mk-futures-view .mk-table td:nth-child(1) { width: 50%; }
  body.mk-futures-view .mk-table th:nth-child(2),
  body.mk-futures-view .mk-table td:nth-child(2) { width: 25%; }
  body.mk-futures-view .mk-table th:nth-child(3),
  body.mk-futures-view .mk-table td:nth-child(3) { width: 25%; }
}

/* Price */
.mk-price { font-weight: 700; font-size: 0.92rem; color: var(--mk-text); }

/* Change (see the App-style Markets block below for the plain colored-text styling) */
.mk-chg { font-weight: 700; font-size: 0.88rem; }

/* Volume */
.mk-vol { color: var(--mk-muted); font-size: 0.83rem; }

/* Trade btn */
.mk-trade-btn {
  display: inline-block;
  background: rgba(0,245,255,0.1);
  color: #00f5ff;
  border: 1px solid rgba(0,245,255,0.3);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.4rem 1.15rem;
  border-radius: 20px;
  text-decoration: none;
  transition: background 0.2s;
  white-space: nowrap;
}

.mk-trade-btn:hover { background: rgba(0,245,255,0.2); }

/* View all link */
.mk-viewall-link {
  display: block;
  text-align: center;
  padding: 1rem;
  color: #6b7a99;
  font-size: 0.82rem;
  text-decoration: none;
  background: #0d0f14;
  border-top: none;
  border-radius: 0 0 14px 14px;
  transition: color 0.2s;
}

.mk-viewall-link:hover { color: var(--mk-brand); }

/* Loading state */
.mk-loading-row td {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--mk-muted);
  font-size: 0.9rem;
}

.mk-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: none;
  border-top-color: var(--mk-brand);
  border-radius: 50%;
  animation: mk-spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}

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

/* ── Mobile ── */
@media (max-width: 900px) {
  .mk-nav { display: none; }
  .mk-hamburger { display: flex; }
}

@media (max-width: 768px) {
  html, body { overflow-x: hidden; width: 100%; }

  /* Header full width, compact */
  .mk-header-inner {
    padding: 0 0.85rem;
    height: 52px;
    width: 100%;
    max-width: 100%;
  }

  /* Main zero side padding */
  .mk-main { padding: 0 0 6rem; width: 100%; }

  /* Tabs: padding handled by .mk-tabs already */
  .mk-tabs-center { margin-bottom: 0; }

  /* Controls row padding */
  .mk-controls-row { padding: 0.6rem 0.85rem; }

  /* Table 100% width, compact cells (Bitget's mobile pair row sits ~60-64px tall) */
  .mk-table { width: 100%; table-layout: fixed; }
  .mk-table thead th { padding: 0.55rem 0.5rem; font-size: 0.73rem; }
  .mk-table tbody td { padding: 0.7rem 0.5rem; }

  /* 4 columns: coin | price | sparkline | 24h change */
  .mk-table th:nth-child(1), .mk-table td:nth-child(1) { width: 38%; }
  .mk-table th:nth-child(2), .mk-table td:nth-child(2) { width: 25%; text-align: right; }
  .mk-table th:nth-child(3), .mk-table td:nth-child(3) { width: 17%; text-align: center; padding-left: 0; padding-right: 0; }
  .mk-table th:nth-child(4), .mk-table td:nth-child(4) { width: 20%; text-align: right; }

  .mk-tabs button { font-size: 1rem; }
  .mk-tabs { gap: 2rem; }
  .mk-coin-ico { width: 30px; height: 30px; }
  .mk-coin-sym { font-size: 0.85rem; line-height: 1.15; }
  .mk-coin-name { font-size: 0.71rem; }
  .mk-coin-vol { line-height: 1.15; }
  .mk-coin-cell { gap: 0.6rem; }
}

/* ══════════════════════════════════════════════════════════
   App-style Markets tab (chart/markets rebuild) — sub-filter
   strip, two-line rows, cyan/pink change text.
   ══════════════════════════════════════════════════════════ */
.mk-subtabs{
  display:flex;gap:.35rem;overflow-x:auto;scrollbar-width:none;
  padding:.55rem .85rem .4rem;background:#0d0f14;
}
.mk-subtabs::-webkit-scrollbar{display:none}
.mk-subtab{
  flex:0 0 auto;background:none;border:none;border-radius:4px;
  color:#95a3bc;font-family:'Pulse','Manrope',sans-serif;font-size:.8rem;font-weight:700;
  padding:.32rem .8rem;cursor:pointer;white-space:nowrap;transition:background .15s,color .15s;
}
.mk-subtab.active{background:rgba(255,255,255,.12);color:#f4f8ff}

/* two-line coin cell */
.mk-coin-base{font-size:.73rem;color:#95a3bc;font-weight:500}
.mk-coin-vol{font-size:.7rem;color:#6b7a99;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mk-coin-sym .q{color:#95a3bc;font-weight:500;font-size:.82rem}

/* price: single bold line, right-aligned, vertically centered against the
   two-line coin cell (Bitget doesn't repeat a redundant "$" line for
   USDT-quoted pairs — the price already *is* the USD-equivalent) */
.mk-price{ font-variant-numeric: tabular-nums; }

/* change as plain colored text (matches Bitget: no pill/box background) */
.mk-chg{
  display:inline-block;min-width:82px;text-align:right;
  font-weight:700;font-size:13px;letter-spacing:-0.3px;
  font-variant-numeric:tabular-nums;
}
.mk-chg.up{color:#00b7d4}
.mk-chg.dn{color:#ff3377}

/* per-row sparkline (Bitget's ~50×16 trend canvas → inline SVG) */
.mk-spark-td{ text-align:center; }
.mk-spark-cell{ display:inline-flex; align-items:center; justify-content:center; line-height:0; }
.mk-spark{ display:block; width:52px; height:16px; }
@media (max-width: 420px){
  .mk-chg{ min-width:64px; }
  .mk-spark, .mk-spark svg{ width:44px; }
}

.mk-table thead th.mk-sortable{cursor:pointer}
.mk-table thead th .mk-sort-caret{opacity:.5;font-size:.7rem}

@media (prefers-reduced-motion: reduce){
  .mk-ticker-track{animation:none}
}

/* 3-column mobile layout: coin | price | 24h change */
@media (max-width: 768px){
  .mk-table thead th, .mk-table tbody td{ display: table-cell; }
  .mk-table th:nth-child(1), .mk-table td:nth-child(1){ width: 44%; }
  .mk-table th:nth-child(2), .mk-table td:nth-child(2){ width: 30%; text-align: right; }
  .mk-table th:nth-child(3), .mk-table td:nth-child(3){ width: 26%; text-align: right; padding-right: .5rem; }
  .mk-subtabs{ padding-left: .85rem; }
}

/* ── Global index cards (Bitget-style) ── */
.mk-index-head{
  font-size: 15px; font-weight: 700; color: var(--mk-text);
  padding: 4px 14px 8px;
}
.mk-index{
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding: 0 12px 14px;
}
.mk-idx-card{
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 2px;
  min-height: 92px;
  padding: 11px 11px 30px;
  border-radius: 12px;
  background: rgba(255,255,255,0.035);
  text-decoration: none;
}
.mk-idx-sym{ font-size: 12px; color: var(--mk-muted); }
.mk-idx-price{ font-size: 16px; font-weight: 700; color: var(--mk-text); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.mk-idx-chg{ font-size: 12px; font-variant-numeric: tabular-nums; }
.mk-idx-chg.up{ color: var(--mk-green); }
.mk-idx-chg.dn{ color: var(--mk-red); }
.mk-idx-sparkwrap{ position: absolute; left: 0; right: 0; bottom: 0; height: 30px; }
.mk-idx-spark{ display: block; width: 100%; height: 100%; }

/* the line draws itself in once on first paint; later 6s refreshes just
   ease the path to its new shape (see renderIndexCards in markets.js) */
@keyframes mk-idx-draw{ from{ stroke-dashoffset: 1; } to{ stroke-dashoffset: 0; } }
@keyframes mk-idx-fade{ to{ opacity: 1; } }
.mk-idx-line{ stroke-dasharray: 1; stroke-dashoffset: 1; animation: mk-idx-draw 1.1s cubic-bezier(0.22,1,0.36,1) forwards; transition: d 1s ease-in-out, stroke .4s ease; }
.mk-idx-area{ opacity: 0; animation: mk-idx-fade 0.5s ease 0.55s forwards; transition: d 1s ease-in-out; }
@media (prefers-reduced-motion: reduce){
  .mk-idx-line{ animation: none; stroke-dashoffset: 0; }
  .mk-idx-area{ animation: none; opacity: 1; }
}
