/* Signed-in app on phones (<= 760px). Loaded by index.html only, after ui-refine.css and
   vip-credits.css, so equal selectors here win. Public pages and the signed-out entry are not touched.
   Measured before (390 x 844): the header was 289px tall and stayed pinned until the page had
   scrolled 289px, so it covered 34% of the screen (39% at 360 x 740) while reading the top of
   every page. Now:
   1. At rest the header is part of the page (scrolls away) and its tabs use 5 columns (2 rows).
   2. Once the full header has scrolled out (body.ui-scrolled, ui-enhance.js) a single pinned row
      appears: logo + the tab strip. The active tab is brought into view (app.js).
   3. Wallet: tabs on one line each, amounts in 2 columns, no empty balance box.
   4. The help button is smaller and the page ends above it. */

@media (max-width: 760px) {
  /* 1. Header at rest: not pinned. */
  html body.user-view:not(.ui-scrolled):not(.admin-view):not(.agent-view) .top {
    position: relative;
    top: auto;
  }
  html body.user-view:not(.admin-view):not(.agent-view) #top-actions > .nav-cluster {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
    padding: 3px;
  }
  html body.user-view:not(.admin-view):not(.agent-view) .nav-cluster .btn.secondary.navbtn {
    min-height: 46px;
    padding: 4px 1px;
    gap: 3px;
    font-size: 11.5px;
  }
  html body.user-view:not(.admin-view):not(.agent-view) .nav-cluster .btn.secondary.navbtn svg {
    width: 16px;
    height: 16px;
  }

  /* 2. Scrolled: one pinned row, logo + scrolling tab strip. The account row and the
     buttons (log out, currency, theme, language) come back when the page is scrolled up. */
  html body.user-view.ui-scrolled:not(.admin-view):not(.agent-view) .top {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  html body.user-view.ui-scrolled:not(.admin-view):not(.agent-view) .top > .brand > div,
  html body.user-view.ui-scrolled:not(.admin-view):not(.agent-view) #top-actions > .nav-utility {
    display: none;
  }
  html body.user-view.ui-scrolled:not(.admin-view):not(.agent-view) .top > .brand .brand-icon {
    width: 32px;
    height: 32px;
  }
  html body.user-view.ui-scrolled:not(.admin-view):not(.agent-view) #top-actions > .nav-cluster {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    padding: 2px;
    overscroll-behavior-x: contain;
    scroll-behavior: smooth;
  }
  html body.user-view.ui-scrolled:not(.admin-view):not(.agent-view) .nav-cluster .btn.secondary.navbtn {
    min-height: 36px;
    padding: 0 11px;
    gap: 5px;
    font-size: 13px;
  }
  html body.user-view.ui-scrolled:not(.admin-view):not(.agent-view) .nav-cluster::-webkit-scrollbar {
    display: none;
  }

  /* While a signed-in reload draws, keep the final header height (2 rows of tabs now). */
  html.nx-auth:not(.nx-ready) body.auth-view .top { min-height: 224px; }

  /* 3. Wallet */
  body.user-view:not(.admin-view):not(.agent-view) .wallet-tabs .wallet-tab-btn {
    min-width: 0;
    padding-inline: 4px;
    gap: 5px;
    font-size: 14px;
  }
  /* "USDT 充值" stays on one line (English labels may still wrap). */
  body.user-view:not(.lang-en):not(.admin-view):not(.agent-view) .wallet-tabs .wallet-tab-btn span {
    white-space: nowrap;
  }
  body.user-view:not(.admin-view):not(.agent-view) .recharge-shell .recharge-amounts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  body.user-view:not(.admin-view):not(.agent-view) .recharge-shell .recharge-amounts .amount-btn {
    min-width: 0;
    min-height: 64px;
    padding: 10px 12px;
  }
  body.user-view:not(.admin-view):not(.agent-view) .recharge-shell .balance-card {
    min-height: 0;
  }

  /* 4. Help button: 48px, and the last controls can scroll clear of it. */
  body.user-view:not(.admin-view):not(.agent-view) .support-widget .support-fab {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
  }
  body.user-view:not(.admin-view):not(.agent-view) main.wrap {
    padding-bottom: 76px;
  }
}

/* Pinned row slides in instead of popping in. */
@media (max-width: 760px) and (prefers-reduced-motion: no-preference) {
  html body.user-view.ui-scrolled:not(.admin-view):not(.agent-view) .top {
    animation: nx-top-in .18s ease-out;
  }
}
@keyframes nx-top-in {
  from { transform: translateY(-100%); }
  to { transform: none; }
}

/* Very narrow phones: one amount per row again. */
@media (max-width: 340px) {
  body.user-view:not(.admin-view):not(.agent-view) .recharge-shell .recharge-amounts {
    grid-template-columns: 1fr;
  }
}
