/* ============================================================
   DexBoss — Mobile / responsive layer
   Targets ≤ 768px; applies to all 10 pages via shared selectors.
   ============================================================ */

/* ====== Phone (≤ 768px) ====== */
@media (max-width: 768px) {

  html, body {
    overflow: auto !important;
    height: auto !important;
    -webkit-text-size-adjust: 100%;
  }

  .app {
    height: auto !important;
    min-height: 100vh;
    grid-template-rows: auto auto 1fr auto !important;
    padding-bottom: 56px;     /* room for bottom tab bar */
  }

  /* ===== TOP NAV ===== */
  .topnav {
    height: 48px;
    padding: 0 12px;
    gap: 8px;
    position: sticky;
    top: 0;
    background: var(--bg-1);
    z-index: 100;
  }
  .topnav__brand-text { font-size: 13px; }
  .topnav__brand-mark { width: 24px; height: 24px; font-size: 12px; }
  /* Replace inline nav links with a horizontal scroll strip */
  .topnav__links {
    margin-left: 4px;
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
    display: none; /* hidden — we'll use bottom tabs instead */
  }
  .topnav__links::-webkit-scrollbar { display: none; }
  .topnav__search {
    display: none;
  }
  .topnav__right { gap: 6px; margin-left: auto; }
  .topnav__right .btn--accent { font-size: 11px; padding: 0 10px; height: 30px; }

  /* Add a hamburger / search trigger */
  .topnav::before {
    content: '⌕';
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    margin-left: auto;
    color: var(--text-2);
    font-size: 18px;
    cursor: pointer;
  }

  /* ===== TICKER ===== */
  .ticker {
    height: 26px !important;
    padding: 0 12px;
    gap: 14px;
    font-size: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .ticker::-webkit-scrollbar { display: none; }

  /* ===== STATUS BAR — hide on mobile ===== */
  .statusbar { display: none !important; }

  /* ===== UNIVERSAL: stack any multi-col workspace ===== */
  .work {
    display: block !important;
    grid-template-columns: 1fr !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* ============================================================
     TOKEN DETAIL — hide trending rail and right rail by default
     ============================================================ */
  .work__col { border-left: none !important; }
  .work .work__col:first-of-type:not(.work__center) {
    display: none; /* hide the trending rail */
  }
  .work__right { display: none; }
  .work__center { overflow: visible !important; height: auto !important; }

  /* Token header — stack vertically */
  .tokhdr {
    flex-wrap: wrap;
    padding: 10px 12px !important;
    gap: 10px !important;
  }
  .tokhdr__id { flex: 1 1 100% !important; width: 100% !important; }
  .tokhdr__stats {
    flex: 1 1 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    border-top: 1px solid var(--line-1);
    border-bottom: 1px solid var(--line-1);
    border-left: none !important;
    border-right: none !important;
    width: 100%;
  }
  .tokhdr__stat {
    border-bottom: 1px solid var(--line-1);
    padding: 6px 10px !important;
  }
  .tokhdr__stat:nth-child(3n) { border-right: none; }
  .tokhdr__stat:nth-last-child(-n+3) { border-bottom: none; }
  .tokhdr__actions { flex: 1 1 100%; justify-content: stretch; }
  .tokhdr__actions .btn { flex: 1; justify-content: center; }

  /* Chart toolbar — horizontal scroll */
  .chart-toolbar {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .chart-toolbar::-webkit-scrollbar { display: none; }

  .chart-canvas {
    min-height: 280px !important;
    flex: none !important;
    height: 280px !important;
  }
  .vol-strip { height: 50px !important; }

  /* Bottom panel trades — horizontal scroll for the table */
  .bottom-panel { min-height: 0 !important; }
  .bottom-panel__body { overflow-x: auto; }
  .tabs {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }

  /* Show right rail as a section that appears below the trades */
  .work .work__right.is-mobile-show {
    display: block !important;
    border-left: none !important;
    border-top: 1px solid var(--line-1);
  }

  /* ============================================================
     DEX SCREENER — keep table, horizontal scroll
     ============================================================ */
  .summary-strip {
    grid-template-columns: repeat(3, 1fr) !important;
    overflow-x: auto;
  }
  .summary-cell { padding: 8px 10px !important; min-width: 110px; border-bottom: 1px solid var(--line-1); }
  .summary-cell:nth-child(3n) { border-right: none; }
  .summary-cell__val { font-size: 14px !important; }
  .filterbar {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filterbar::-webkit-scrollbar { display: none; }

  .screener-wrap { overflow-x: auto; }
  .screener { min-width: 980px; }

  .paginate {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* ============================================================
     LIVE FEED — stack feed + sidebar
     ============================================================ */
  .feed-col { border-right: none !important; }
  .side-col {
    border-left: none !important;
    border-top: 1px solid var(--line-1);
    height: auto !important;
  }
  .feedbar {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .feedbar::-webkit-scrollbar { display: none; }
  .stream { overflow-x: auto; }
  .stream-table { min-width: 880px; }

  /* Heatmap — 3 cols on mobile */
  .heatmap { grid-template-columns: repeat(3, 1fr) !important; }

  /* ============================================================
     LEADERBOARD
     ============================================================ */
  .lb-hero {
    grid-template-columns: 1fr !important;
  }
  .lb-hero__l { border-right: none !important; }
  .lb-hero__r { grid-template-columns: repeat(2, 1fr) !important; }
  .lb-stat { padding: 8px 12px !important; border-bottom: 1px solid var(--line-1); }
  .lb-stat:nth-child(2n) { border-right: none; }
  .lb-bar {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .lb-bar::-webkit-scrollbar { display: none; }
  .lb-wrap { overflow-x: auto; }
  .lb-table { min-width: 1080px; }

  /* ============================================================
     WALLET DETAIL
     ============================================================ */
  .right { display: none; }            /* hide copy-trade rail */
  .center { overflow: visible !important; height: auto !important; }
  .whdr {
    flex-wrap: wrap;
    padding: 10px 12px !important;
    gap: 10px !important;
  }
  .whdr__id { flex: 1 1 100% !important; }
  .whdr__stats {
    flex: 1 1 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    border-left: none !important;
    border-right: none !important;
    border-top: 1px solid var(--line-1);
    border-bottom: 1px solid var(--line-1);
  }
  .whdr__stat {
    border-bottom: 1px solid var(--line-1);
    padding: 6px 10px !important;
  }
  .whdr__stat:nth-child(3n) { border-right: none; }
  .whdr__stat:nth-last-child(-n+3) { border-bottom: none; }
  .whdr__actions { flex: 1 1 100%; justify-content: stretch; }
  .whdr__actions .btn { flex: 1; justify-content: center; }
  .pnl-canvas { height: 200px !important; }
  .pnl-toolbar {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .pnl-toolbar::-webkit-scrollbar { display: none; }
  .wbottom__body { overflow-x: auto; }
  .htable { min-width: 880px; }

  /* ============================================================
     PORTFOLIO — 2x2 → single column
     ============================================================ */
  .port-grid {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto !important;
    height: auto !important;
    overflow: visible !important;
  }
  .port-card {
    border-right: none !important;
    border-bottom: 1px solid var(--line-1) !important;
    min-height: 360px;
  }
  .holdings-layout { grid-template-columns: 1fr !important; }
  .donut-wrap { border-right: none !important; border-bottom: 1px solid var(--line-1); }
  .ports-tbl-wrap { overflow-x: auto; }
  .page-hero {
    flex-wrap: wrap;
    padding: 12px !important;
    gap: 12px !important;
  }
  .page-hero__stats {
    flex: 1 1 100%;
    margin-left: 0 !important;
    border-left: none !important;
    border-top: 1px solid var(--line-1);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .page-hero__stats::-webkit-scrollbar { display: none; }
  .page-hero__stat { min-width: 140px; }
  .subbar {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .subbar::-webkit-scrollbar { display: none; }

  /* ============================================================
     ALERTS — stack rules + side form
     ============================================================ */
  .alerts-layout {
    grid-template-columns: 1fr !important;
    height: auto !important;
    overflow: visible !important;
  }
  .alerts-main { border-right: none !important; }
  .alerts-side {
    border-top: 1px solid var(--line-1);
    overflow: visible !important;
  }
  .arule {
    grid-template-columns: 28px 1fr;
    grid-template-rows: auto auto;
    padding: 10px 12px !important;
    gap: 8px;
  }
  .arule__icon { grid-column: 1; grid-row: 1 / 3; }
  .arule__icon { width: 28px; height: 28px; }
  .arule > div:nth-child(2) { grid-column: 2; grid-row: 1; }
  .arule__chan { grid-column: 2; grid-row: 2; }
  .arule__stats { display: none; }
  .arule > div:last-child { grid-column: 2; grid-row: 2; justify-self: end; }
  .chan-grid { grid-template-columns: 1fr !important; }
  .template-grid { grid-template-columns: 1fr !important; }

  /* ============================================================
     SETTINGS — sidebar nav becomes horizontal tabs
     ============================================================ */
  .set-layout {
    grid-template-columns: 1fr !important;
    overflow: visible !important;
    height: auto !important;
  }
  .set-nav {
    border-right: none !important;
    border-bottom: 1px solid var(--line-1);
    padding: 6px 0 !important;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    gap: 0;
  }
  .set-nav::-webkit-scrollbar { display: none; }
  .set-nav__group { display: none; }
  .set-nav__item {
    border-left: none !important;
    border-bottom: 2px solid transparent;
    padding: 8px 12px !important;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .set-nav__item.is-active {
    border-bottom-color: var(--accent);
    background: transparent !important;
  }
  .set-main { padding: 16px 14px !important; }
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
  }
  .integrations {
    grid-template-columns: 1fr !important;
  }
  .theme-row {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ============================================================
     PRICING — 4 cols → stack
     ============================================================ */
  .pricing-wrap { padding: 24px 16px 32px !important; }
  .pricing-hdr h1 { font-size: 28px !important; }
  .plans {
    grid-template-columns: 1fr !important;
  }
  .compare-table-wrap { overflow-x: auto; }
  .compare-table { min-width: 720px; }
  .faq-grid { grid-template-columns: 1fr !important; }

  /* ============================================================
     ONBOARDING — 2 cols → stack
     ============================================================ */
  .onb {
    grid-template-columns: 1fr !important;
    min-height: 100vh;
  }
  .onb-pitch {
    padding: 28px 24px 20px !important;
    border-right: none !important;
    border-bottom: 1px solid var(--line-1);
  }
  .onb-pitch__h1 { font-size: 36px !important; }
  .onb-metrics { grid-template-columns: 1fr 1fr !important; }
  .onb-connect { padding: 28px 20px 40px !important; }
  .onb-card__title { font-size: 22px !important; }
  .onb-step { flex-wrap: wrap; gap: 6px; }

  /* ============================================================
     INDEX HUB — single column on phones
     ============================================================ */
  body { padding: 24px 0 !important; }
  .hub { padding: 0 16px !important; }
  .hub-title { font-size: 26px !important; }
  .hub-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .hub-meta { text-align: left; }
  .cards { grid-template-columns: 1fr !important; }

  /* ============================================================
     BOTTOM TAB BAR — injected via mobile.js
     ============================================================ */
  .mob-tabbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    background: var(--bg-1);
    border-top: 1px solid var(--line-1);
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    z-index: 99;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mob-tabbar__btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-3);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
  }
  .mob-tabbar__btn .ico {
    font-size: 18px;
    line-height: 1;
  }
  .mob-tabbar__btn.is-active {
    color: var(--accent);
  }
  .mob-tabbar__btn .dot {
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--up);
    display: inline-block;
    margin-right: 2px;
    vertical-align: middle;
    box-shadow: 0 0 4px var(--up);
  }

  /* Tweaks panel — full-width drawer on mobile */
  .tweaks-shell {
    top: auto !important;
    bottom: 70px !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
  }
  .tweaks-trigger {
    bottom: 70px !important;
    right: 12px !important;
  }
}

/* ====== Tablet (769px – 1024px) — softer adjustments ====== */
@media (min-width: 769px) and (max-width: 1024px) {

  /* Workspaces: keep 2 cols where there were 3 */
  .work {
    grid-template-columns: 1fr 300px !important;
  }
  .work__col:first-of-type:not(.work__center) {
    display: none;     /* hide left rail at tablet too */
  }

  .topnav__search { max-width: 260px; }
  .topnav__links .topnav__link { padding: 5px 8px; font-size: 11px; }

  /* Pricing: 2 cols */
  .plans { grid-template-columns: 1fr 1fr !important; }

  /* Portfolio: keep 2x2 but smaller */
  .lb-hero__r { grid-template-columns: repeat(4, 1fr) !important; }

  /* Tables — allow horizontal scroll if needed */
  .screener-wrap, .lb-wrap, .stream { overflow-x: auto; }
}
