/* Nova terminal — phone layout (≤767px), loaded after nova-terminal.css on market-detail only.
   Cloned from KCEX's mobile spot page: Spot / Futures sections, a pair bar with a trade / chart
   switch, then either
     trade screen: order form (left) + order book (right), orders underneath;
     chart screen: chart + indicators, Order Book / Market Trades, Buy / Sell bar.
   Driven by nova-mobile-terminal.js. Nothing here applies above 767px except hiding the
   phone-only controls. */

.kx-m-sec, .kx-m-views, .kx-m-bar, .kx-m-scrim, .kx-m-sheethead, .kx-m-symclose, .kx-m-back,
.kx-m-otype, .kx-m-dep, .kx-m-only { display: none; }

@media (max-width: 767px) {
  html.m-lock-sym, html.m-lock-sym body { overflow: hidden; }
  body.kx-page .lk-header { display: none; }
  .kx-term { font-size: 12px; background: var(--kx-bg); padding-bottom: var(--m-tab); }
  .kx-term, .kx-body, .kx-chart-col, .kx-book-col, .kx-form-col, .kx-blotter, .kx-head { background: var(--kx-bg); }
  .kx-ticker, .kx-head__price, .kx-head__metrics, .kx-form-tabs, .kf-tabs,
  .kf-fees, .kx-wallet, .kf-wallet, .kf-divide, .kx-book-ratio { display: none; }
  .kx-term input { font-size: 16px; }

  /* ---- Spot / Futures sections ---- */
  .kx-m-sec { display: flex; gap: 24px; padding: calc(4px + env(safe-area-inset-top)) 16px 0; }
  .kx-m-sec button {
    height: 40px; padding: 0; border: 0; background: none; color: var(--kx-faint);
    font-size: 16px; font-weight: 600;
  }
  .kx-m-sec button.is-on { color: var(--kx-text); }

  /* ---- Pair bar: pair on the left, trade / chart switch on the right ---- */
  .kx-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    height: 48px; padding: 0 16px; border: 0;
  }
  .kx-head__sym { display: flex; align-items: center; gap: 8px; padding: 0; margin: 0; border: 0; position: static; min-width: 0; }
  .kx-head__sym .asset-ico, .kx-head__sym .asset-ico img, .kx-head__sym > img { width: 20px; height: 20px; flex: none; }
  .kx-head__sym-btn { min-height: 44px; gap: 6px; padding: 0; }
  .kx-head__sym-name { font-size: 16px; font-weight: 600; }
  .kx-head__sym-name small { font-size: 14px; }
  .kx-m-views { display: flex; padding: 2px; gap: 2px; border: 1px solid var(--kx-line); border-radius: 6px; }
  .kx-m-views button {
    display: flex; align-items: center; justify-content: center; width: 36px; height: 28px; padding: 0;
    border: 0; border-radius: 4px; background: none; color: var(--kx-faint);
  }
  .kx-m-views button.is-on { background: var(--kx-chip); color: var(--kx-text); }

  /* Pair picker: full screen, its own Close at the top. */
  .kx-head__sym-menu:not([hidden]) {
    position: fixed; inset: 0; z-index: 130; width: auto; max-height: none; margin: 0;
    display: flex; flex-direction: column; border: 0; border-radius: 0; box-shadow: none;
    padding: calc(8px + env(safe-area-inset-top)) 16px calc(8px + env(safe-area-inset-bottom));
    background: var(--kx-bg); overflow: hidden;
  }
  .kx-m-symclose {
    display: block; order: -1; align-self: flex-end; height: 44px; padding: 0 4px; margin-bottom: 4px;
    border: 0; background: none; color: var(--kx-text); font-size: 16px; font-weight: 500;
  }
  .kx-head__sym-search { display: none; }
  /* TP / SL boxes: their labels are hidden here, so the spacing that hung off the label is gone. */
  .kf-extra .kf-field__box ~ .kf-field__box { margin-top: 8px; }
  .kx-head__sym-tab { font-size: 14px; }
  .kx-head__sym-cols, .kx-head__sym-row { grid-template-columns: 22px minmax(0, 1fr) auto 72px; }
  .kx-head__sym-cols > :nth-child(5), .kx-head__sym-row > :nth-child(5) { display: none; }
  .kx-head__sym-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .kx-head__sym-row { min-height: 52px; font-size: 14px; }

  /* =================================== Trade screen =================================== */
  .kx-term[data-m-view="trade"] .kx-body {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); grid-template-areas: "form book" "blotter blotter";
    column-gap: 16px; row-gap: 0; padding: 4px 16px 0;
  }
  .kx-term[data-m-view="trade"] .kx-chart-col { display: none; }

  /* ---- Order form (left column) ---- */
  .kx-form-col { position: static; transform: none; visibility: visible; max-height: none; overflow: visible; border: 0; padding: 0; }
  .kx-form-body, .kf { padding: 0; }
  .kf-oc { height: 32px; border-radius: 4px; background: var(--kx-chip); }
  .kf-oc button { border-radius: 4px; font-size: 14px; font-weight: 500; line-height: 32px; color: var(--kx-text); }
  .kf-lev { padding: 8px 0 0; }
  .kf-flash:empty { display: none; }

  .kx-m-otype { display: block; margin-top: 8px; }
  .kx-m-otype .nsel, .kx-m-otype .nsel__btn { width: 100%; }
  .kx-m-otype .nsel__btn {
    position: relative; justify-content: center; height: 36px; padding: 0 28px; border: 0; border-radius: 4px;
    background-color: var(--kx-chip); background-position: right 12px center; color: var(--kx-text); font-size: 14px; font-weight: 600;
  }

  .kf-inputs { margin-top: 8px; gap: 8px; }
  .kf-field { position: relative; }
  .kf-field__box { height: 42px; padding: 0 10px; border-radius: 4px; }
  .kf-field__box input { padding: 0; font-size: 14px; }
  .kf-field__box input::placeholder { color: var(--kx-faint); }
  .kf-field__unit { color: var(--kx-text); font-size: 14px; font-weight: 500; }
  .kx-m-only { display: inline; }
  /* Labels: only the price keeps one, small, inside the top-left of its box. Qty / Total use
     their placeholders instead. */
  .kf-field__label { display: none; }
  /* Fields that need their caption (price, trigger price, futures qty with its USDT / coin
     switch, spot market qty with its Total / Qty switch) keep it small in the box's top-left. */
  .kf-field:has([data-kx-price-input]) > .kf-field__label, .kf-field:has([data-kf-price]) > .kf-field__label,
  .kf-field:has([data-kx-trigger-input]) > .kf-field__label, .kf-field:has([data-kf-trigger]) > .kf-field__label,
  .kf-field:has([data-kf-qty]) > .kf-field__label,
  .kf-field:has([data-kx-qty-input]) > .kf-field__label:has(.kf-dd:not([hidden])) {
    display: flex; position: absolute; top: 5px; left: 10px; z-index: 2; margin: 0; min-height: 0;
    color: var(--kx-faint); font-size: 10px; line-height: 12px;
  }
  .kf-field > .kf-field__label .kf-dd__btn { font-size: 10px; line-height: 12px; color: var(--kx-faint); }
  .kf-field:has(> .kf-field__label .kf-dd:not([hidden])) input::placeholder { color: transparent; }
  .kf-field:has([data-kx-price-input]) .kf-field__box input, .kf-field:has([data-kf-price]) .kf-field__box input,
  .kf-field:has([data-kx-trigger-input]) .kf-field__box input, .kf-field:has([data-kf-trigger]) .kf-field__box input,
  .kf-field:has([data-kf-qty]) .kf-field__box input,
  .kf-field:has(> .kf-field__label .kf-dd:not([hidden])) .kf-field__box input { padding-top: 14px; }
  /* Spot price: no BBO / Latest button on phones. Futures keep "Latest" as a separate box. */
  [data-kx-latest] { display: none; }
  .kf-field:has([data-kf-price]) .kf-field__box { padding-right: 66px; background: none; isolation: isolate; }
  .kf-field:has([data-kf-price]) .kf-field__box::before {
    content: ""; position: absolute; top: 0; bottom: 0; left: 0; right: 0; border-radius: 4px; background: var(--kx-chip); z-index: -1;
  }
  .kf-field:has([data-kf-price]) .kf-field__box:focus-within { border-color: transparent; }
  /* No "Latest" (fill with the mark price) button on the phone form. */
  [data-kf-latest] { display: none !important; }
  /* Margin under Open Long / Open Short: centred under its own button, label and amount together
     (split to the edges, one half's amount ran into the other half's label). */
  .kf-margins > div { justify-content: center; flex-wrap: wrap; min-width: 0; text-align: center; }
  /* A huge amount wraps inside its own half instead of running off the form. */
  .kf-margins strong { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  /* Max Long / Max Short: one under the other, both from the left edge. */
  .kf-sum__row--max { flex-direction: column; gap: 4px; }
  .kf-sum__row--max > div + div { margin-left: 0; }

  /* Slider: 0 / 25 / 50 / 75 / 100% under the dots. */
  .kf-slider { margin: 6px 0 4px; padding: 0 6px; touch-action: none; }
  /* The 12px track is a thin target: an invisible 12px margin all round makes it easy to grab, so a
     drag never lands beside it — where the browser would read it as a back / forward swipe. */
  .kf-slider__track::before { content: ""; position: absolute; inset: -12px -10px; }
  /* The % captions sit over the lower half of that margin — let touches pass through to the track. */
  .kf-slider__marks, .kf-slider__marks span { pointer-events: none; }
  .kf-slider__marks span { color: var(--kx-faint); font-size: 12px; }
  .kf-slider + .kf-field--total { margin-top: 0; }

  .kf-sum, .kf-sum--spot { margin: 8px 0 12px; }
  .kf-sum__line, .kf-sum__avail { display: flex; align-items: center; margin-top: 4px; font-size: 12px; line-height: 18px; }
  .kf-sum__line > span:first-child { margin-right: auto; }
  .kf-sum__avail > span:first-child { margin-right: auto; }
  .kx-m-dep { display: inline-flex; margin-right: 4px; color: var(--kx-text); }
  .kf-sum__line strong, .kf-sum__avail strong { color: var(--kx-text); font-weight: 600; margin-left: 0; }
  .kf-checks { padding: 0 0 8px; flex-wrap: wrap; row-gap: 8px; }
  .kf-btn, .kf-btn--wide { height: 36px; border-radius: 18px; font-size: 14px; font-weight: 600; }
  .kf-btns .kx-guest-cta { min-height: 36px; }
  .kf-btns { flex-wrap: wrap; }

  /* ---- Order book (right column) ---- */
  .kx-term[data-m-view="trade"] .kx-book-tabs { display: none; }
  .kx-term[data-m-view="trade"] .kx-book-col > [data-kx-book-panel]:not([hidden]) { top: 0; }
  .kx-term[data-m-view="trade"] .kx-book-tools { order: 9; margin-top: auto; padding: 8px 0 0; }
  .kx-term[data-m-view="trade"] .kx-book-head { padding: 0 0 6px; line-height: 16px; }
  .kx-term[data-m-view="trade"] .kx-book-head span { white-space: normal; width: min-content; flex: none; }
  .kx-term[data-m-view="trade"] .kx-book-head span:first-child { margin-right: auto; }
  .kx-term[data-m-view="trade"] .kx-book-head span:nth-child(3),
  .kx-term[data-m-view="trade"] .kx-book-row__tot { display: none; }
  .kx-term[data-m-view="trade"] .kx-book-row { padding: 0; height: var(--kx-row-h, 20px); }
  .kx-term[data-m-view="trade"] .kx-book-tools { align-items: flex-end; box-sizing: border-box; }
  .kx-term[data-m-view="trade"] .kx-book-row__qty { width: auto; margin-left: auto; color: var(--kx-text); }
  .kx-term[data-m-view="trade"] .kx-book-mid { flex-wrap: wrap; row-gap: 0; column-gap: 4px; padding: 6px 0; background: none; }
  .kx-term[data-m-view="trade"] .kx-book-mid__px { font-size: 18px; }
  .kx-term[data-m-view="trade"] .kx-book-mid__usd { flex-basis: 100%; color: var(--kx-faint); }
  .kx-term[data-m-view="trade"] .kx-book-mid__usd:not(:empty)::before { content: "\2248 "; }
  /* Bottom of the book: grouping box on the left, one layout icon (cycles) on the right. */
  .kx-term[data-m-view="trade"] .kx-book-tools { flex-direction: row-reverse; gap: 8px; }
  .kx-term[data-m-view="trade"] .kx-book-tick { flex: 1; justify-content: space-between; height: 32px; padding: 0 6px; border-radius: 4px; }
  .kx-term[data-m-view="trade"] .kx-book-tick button { width: 24px; height: 24px; font-size: 14px; color: var(--kx-text); }
  .kx-term[data-m-view="trade"] .kx-book-tick span { font-size: 14px; color: var(--kx-text); }
  .kx-term[data-m-view="trade"] .kx-book-modes button:not(.is-active) { display: none; }

  /* ---- Orders underneath ---- */
  .kx-blotter { margin: 16px -16px 0; border-top: 0; }
  .kx-blotter__tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; column-gap: 20px; border-bottom: 1px solid var(--kx-line); }
  .kx-blotter__tabs::-webkit-scrollbar { display: none; }
  .kx-blotter__tabs button { flex: none; height: 44px; font-size: 14px; white-space: nowrap; }
  .kx-blotter__tabs button[hidden] { display: none; }
  .kx-blotter__tabs button.is-active::after { left: 50%; right: auto; width: 16px; margin-left: -8px; background: var(--kx-text); }
  .kx-table.is-cards tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kx-table.is-cards td { font-size: 14px; }
  .kx-table.is-cards .kx-act .kx-close .kx-btn, .kx-table.is-cards .kx-act form .kx-btn { height: 40px; font-size: 14px; }

  /* =================================== Chart screen =================================== */
  .kx-term[data-m-view="chart"] .kx-body { grid-template-columns: minmax(0, 1fr); grid-template-areas: "chart" "book"; gap: 0; padding: 0; }
  .kx-term[data-m-view="chart"] .kx-form-col, .kx-term[data-m-view="chart"] .kx-blotter { display: none; }
  .kx-term[data-m-view="chart"] { padding-bottom: calc(64px + var(--m-tab)); }
  .kx-chart-stage { height: min(52dvh, 420px); flex: 0 0 min(52dvh, 420px); }
  .kx-indicator-bar__scroll { overflow-x: auto; scrollbar-width: none; }
  .kx-term[data-m-view="chart"] .kx-book-col { height: min(60dvh, 520px); }
  .kx-term[data-m-view="chart"] .kx-book-tabs { gap: 24px; height: 44px; border-bottom: 0; }
  .kx-term[data-m-view="chart"] .kx-book-tabs button { height: 44px; font-size: 14px; }
  .kx-term[data-m-view="chart"] .kx-book-col > [data-kx-book-panel]:not([hidden]) { top: 44px; }
  .kx-term[data-m-view="chart"] .kx-m-bar {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    position: fixed; left: 0; right: 0; bottom: var(--m-tab); z-index: 59;
    padding: 8px 16px; background: transparent;
  }
  .kx-m-bar button { height: 44px; border: 0; border-radius: 22px; color: #fff; font-size: 16px; font-weight: 600; }
  .kx-m-bar__buy { background: var(--kx-green); }
  .kx-m-bar__sell { background: var(--kx-red); }

  /* Leverage / close / TP-SL dialogs slide up from the bottom. */
  .kf-modal { align-items: flex-end; }
  .kf-modal__panel { width: 100%; margin-top: auto; border: 0; border-radius: 16px 16px 0 0; padding-top: 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  /* Grab bar on top (nova-mobile.js adds it; dragging it down closes the dialog). */
  .kf-modal__panel > .m-grab { position: static; margin: 0 -24px 12px; padding: 10px 0 6px; background: none; }
}
