/* ==========================================================================
 * BUFFTRAFFIC — MOBILE-FIRST RESPONSIVE LAYER (Feed, User Dashboard, Admin)
 * Breakpoints:
 *   - Mobile:  < 640px  (tables -> cards at < 768px)
 *   - Tablet:  640px – 1024px
 *   - Desktop: > 1024px (preserves existing desktop layout cleanly)
 * Standards:
 *   - Touch targets >= 44px, button spacing >= 8px
 *   - Input/Select/Textarea font-size >= 16px on mobile (prevents iOS auto-zoom)
 *   - Tabular numerals on all metrics & balances
 * ========================================================================== */

:root {
  --bt-mob-header-h: 56px;
  --bt-mob-bottom-h: 60px;
  --bt-mob-safe-bottom: env(safe-area-inset-bottom, 0px);
  --bt-mob-bg: #F8FAFC;
  --bt-mob-surface: #FFFFFF;
  --bt-mob-border: #E2E8F0;
  --bt-mob-text: #0F172A;
  --bt-mob-muted: #64748B;
  --bt-mob-primary: #2563EB;
  --bt-mob-teal: #0D9488;
  --bt-mob-danger: #DC2626;
}

/* Desktop defaults: keep all mobile-only chrome hidden above 1024px */
#bt-mob-bottom-nav,
#bt-mob-drawer,
#bt-mob-drawer-backdrop,
#bt-mob-actionsheet-backdrop,
#bt-mob-chat-backdrop,
.bt-mob-only,
#bt-mob-feed-quickbar,
#bt-mob-feed-wallet-pill,
#bt-mob-feed-drawer-btn,
.bt-mob-inline-ad,
.bt-mob-chat-sheet-bar,
.bt-mob-filter-bar-btn,
.bt-mob-filter-sheet-backdrop,
.bt-mob-sheet-handle,
.bt-mob-sheet-cancel {
  display: none;
}

/* ==========================================================================
 * 1. MOBILE & TABLET NAVIGATION SHELL (<= 1024px)
 * ========================================================================== */
@media (max-width: 1024px) {
  html,
  body {
    overflow-x: clip;
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.12);
  }

  /* Add bottom breathing room on authenticated app pages for fixed Bottom Nav */
  body.bt-mob-nav-active .feed-page,
  body.bt-mob-nav-active .app-page,
  body.bt-mob-nav-active.bt-user-admin-mode .app-page:not(.admin-page),
  body.bt-mob-nav-active.bt-adm-ent-mode .admin-page {
    padding-bottom: calc(var(--bt-mob-bottom-h) + var(--bt-mob-safe-bottom) + 20px) !important;
  }

  /* ---- FIXED BOTTOM NAVIGATION BAR (60px + safe-area) ---- */
  body.bt-mob-nav-active #bt-mob-bottom-nav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    align-items: center;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1250;
    min-height: calc(var(--bt-mob-bottom-h) + var(--bt-mob-safe-bottom));
    padding: 4px 6px calc(4px + var(--bt-mob-safe-bottom));
    background: rgba(255, 255, 255, 0.96);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--bt-mob-border);
    box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.06);
  }

  .bt-mob-nav-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    padding: 4px 2px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--bt-mob-muted);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.1;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s ease, background 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
  }

  .bt-mob-nav-item:active {
    background: rgba(37, 99, 235, 0.08);
  }

  .bt-mob-nav-item svg {
    width: 21px;
    height: 21px;
    stroke-width: 2;
    flex-shrink: 0;
  }

  .bt-mob-nav-item span.bt-mob-nav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .bt-mob-nav-item.is-active {
    color: var(--bt-mob-primary);
    font-weight: 700;
  }

  .bt-mob-nav-item.is-active.is-seo {
    color: var(--bt-mob-teal);
  }

  .bt-mob-nav-item.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: currentColor;
  }

  .bt-mob-nav-badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 22px);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #EF4444;
    color: #FFFFFF;
    font-size: 10px;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 1px 4px rgba(239, 68, 68, 0.45);
  }

  /* ---- SLIDE-OVER MENU DRAWER (Dark Mode, Account, Workspace, Logout) ---- */
  #bt-mob-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1390;
    background: rgba(15, 23, 42, 0.48);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.bt-mob-drawer-open #bt-mob-drawer-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  #bt-mob-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1400;
    width: min(86vw, 320px);
    background: var(--bt-mob-surface);
    color: var(--bt-mob-text);
    box-shadow: -14px 0 36px rgba(15, 23, 42, 0.2);
    transform: translateX(104%);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    overflow-y: auto;
    padding-bottom: calc(18px + var(--bt-mob-safe-bottom));
  }

  body.bt-mob-drawer-open #bt-mob-drawer {
    transform: translateX(0);
  }

  .bt-mob-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--bt-mob-border);
    min-height: var(--bt-mob-header-h);
  }

  .bt-mob-drawer-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 0.04em;
    color: var(--bt-mob-text);
  }

  .bt-mob-drawer-close {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--bt-mob-border);
    background: var(--bt-mob-bg);
    color: var(--bt-mob-text);
    font-size: 22px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  .bt-mob-drawer-profile {
    margin: 14px 16px 10px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--bt-mob-bg);
    border: 1px solid var(--bt-mob-border);
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .bt-mob-drawer-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563EB, #0D9488);
    color: #FFFFFF;
    font-weight: 800;
    font-size: 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    flex-shrink: 0;
  }

  .bt-mob-drawer-user {
    min-width: 0;
    flex: 1;
  }

  .bt-mob-drawer-user strong {
    display: block;
    font-size: 14px;
    font-weight: 800;
    color: var(--bt-mob-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .bt-mob-drawer-user small {
    display: block;
    font-size: 12px;
    color: var(--bt-mob-muted);
    margin-top: 2px;
  }

  .bt-mob-drawer-wallets {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 0 16px 14px;
  }

  .bt-mob-drawer-wcard {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--bt-mob-border);
    background: var(--bt-mob-surface);
  }

  .bt-mob-drawer-wcard span {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--bt-mob-muted);
  }

  .bt-mob-drawer-wcard strong {
    display: block;
    font-size: 16px;
    font-weight: 800;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
  }

  .bt-mob-drawer-wcard.is-traffic strong { color: #2563EB; }
  .bt-mob-drawer-wcard.is-seo strong { color: #0D9488; }

  .bt-mob-drawer-section {
    padding: 6px 12px;
  }

  .bt-mob-drawer-label {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bt-mob-muted);
    padding: 6px 8px;
  }

  .bt-mob-drawer-btn {
    width: 100%;
    min-height: 46px;
    padding: 0 12px;
    margin-bottom: 4px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--bt-mob-text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    text-align: left;
  }

  .bt-mob-drawer-btn:active {
    background: var(--bt-mob-bg);
  }

  .bt-mob-drawer-btn-left {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .bt-mob-drawer-btn svg {
    width: 18px;
    height: 18px;
    color: var(--bt-mob-muted);
    flex-shrink: 0;
  }

  .bt-mob-drawer-btn.is-danger {
    color: var(--bt-mob-danger);
  }
  .bt-mob-drawer-btn.is-danger svg {
    color: var(--bt-mob-danger);
  }

  .bt-mob-switch-pill {
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: #CBD5E1;
    position: relative;
    transition: background 0.18s ease;
    flex-shrink: 0;
  }

  .bt-mob-switch-pill::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #FFFFFF;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.18s ease;
  }

  .bt-mob-switch-pill.is-on {
    background: #2563EB;
  }

  .bt-mob-switch-pill.is-on::after {
    transform: translateX(18px);
  }

  /* ==========================================================================
   * 2. FEED PAGE MOBILE OPTIMIZATION (/feed)
   * ========================================================================== */

  /* Minimal 56px Sticky Top Header on Feed */
  .feed-page .feed-shell-topbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 1200 !important;
    min-height: var(--bt-mob-header-h) !important;
    height: var(--bt-mob-header-h) !important;
    padding: 0 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    background: rgba(255, 255, 255, 0.96) !important;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--bt-mob-border) !important;
  }

  .feed-page .feed-brand {
    font-size: 15px !important;
    font-weight: 900 !important;
    letter-spacing: 0.03em !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  /* Hide desktop center nav on mobile (moved to Bottom Bar) */
  .feed-page .feed-shell-topbar .feed-topbar-center {
    display: none !important;
  }

  .feed-page .feed-shell-topbar .feed-topbar-actions {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
    margin-left: auto !important;
  }

  /* Hide desktop topbar actions moved into Drawer / Bottom Bar, keep Notification bell! */
  .feed-page .feed-topbar-actions .feed-user-pill,
  .feed-page .feed-topbar-actions .feed-circle-link,
  .feed-page .feed-topbar-actions > button.feed-circle-action {
    display: none !important;
  }

  /* Keep notification bell visible & 44px touch friendly */
  .feed-page .feed-topbar-actions .feed-notification-wrap {
    display: inline-flex !important;
    position: relative !important;
  }

  .feed-page .feed-topbar-actions .feed-notification-wrap > .feed-circle-action {
    display: inline-flex !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    padding: 0 !important;
    margin: 0 !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .feed-page .feed-notification-menu {
    position: fixed !important;
    top: calc(var(--bt-mob-header-h) + 6px) !important;
    right: 10px !important;
    left: 10px !important;
    width: auto !important;
    max-width: 420px !important;
    margin-left: auto !important;
    max-height: 70dvh !important;
    z-index: 1350 !important;
  }

  /* Dual Wallet Pill in Topbar */
  #bt-mob-feed-wallet-pill {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid #DBEAFE;
    background: #EFF6FF;
    color: #0F172A;
    font-size: 11.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    cursor: pointer;
  }

  #bt-mob-feed-wallet-pill .bt-mw-t { color: #1D4ED8; }
  #bt-mob-feed-wallet-pill .bt-mw-sep { color: #94A3B8; font-weight: 400; }
  #bt-mob-feed-wallet-pill .bt-mw-s { color: #0F766E; }

  /* Hamburger Menu Drawer Button in Topbar */
  #bt-mob-feed-drawer-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 10px;
    border: 1px solid var(--bt-mob-border);
    background: var(--bt-mob-bg);
    color: var(--bt-mob-text);
    cursor: pointer;
    flex-shrink: 0;
  }

  /* 3-Column Desktop -> 1-Column Mobile Feed Shell */
  .feed-page .feed-shell {
    width: 100% !important;
    max-width: 760px !important;
    height: auto !important;
    min-height: calc(100dvh - var(--bt-mob-header-h) - var(--bt-mob-bottom-h)) !important;
    margin: 0 auto !important;
    padding: 12px 12px 24px !important;
    display: block !important;
    overflow: visible !important;
  }

  .feed-page .feed-main {
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    padding-right: 0 !important;
    gap: 12px !important;
  }

  /* Hide Right Rail Ads from main flow on mobile (inline ads injected every 4-5 posts) */
  .feed-page .feed-right-rail {
    display: none !important;
  }

  /* Hide Chat Sidebar from main flow, transform into sleek Full-Bottom Sheet when .bt-mob-chat-open */
  #bt-mob-chat-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1310;
    background: rgba(15, 23, 42, 0.54);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
  }

  body.bt-mob-chat-open #bt-mob-chat-backdrop {
    display: block;
  }

  .feed-page .feed-sidebar {
    display: none !important;
  }

  body.bt-mob-chat-open .feed-page .feed-sidebar {
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    height: min(86dvh, calc(100dvh - 44px)) !important;
    z-index: 1320 !important;
    border-radius: 22px 22px 0 0 !important;
    border: 0 !important;
    background: #FFFFFF !important;
    box-shadow: 0 -14px 40px rgba(15, 23, 42, 0.28) !important;
    overflow: hidden !important;
    animation: btMobSheetUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .bt-mob-chat-sheet-bar {
    display: flex !important;
    flex-direction: column;
    padding: 8px 16px 11px;
    background: #FFFFFF;
    border-bottom: 1px solid #E2E8F0;
    flex-shrink: 0;
  }

  .bt-mob-chat-sheet-pill {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: #CBD5E1;
    margin: 0 auto 10px;
  }

  .bt-mob-chat-sheet-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .bt-mob-chat-sheet-title {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .bt-mob-chat-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #EFF6FF;
    color: #2563EB;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .bt-mob-chat-sheet-title strong {
    display: block;
    font-size: 15px;
    font-weight: 800;
    color: #0F172A;
    line-height: 1.2;
  }

  .bt-mob-chat-sheet-title small {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 600;
    color: #64748B;
    margin-top: 1px;
  }

  .bt-mob-chat-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10B981;
    display: inline-block;
  }

  .bt-mob-chat-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 0;
    background: #F1F5F9;
    color: #475569;
    font-size: 21px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
  }

  .bt-mob-chat-close-btn:active {
    background: #E2E8F0;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-thread-head {
    display: none !important;
  }

  /* Modern Messenger / Zalo-style Chat List & Bubbles */
  body.bt-mob-chat-open .feed-sidebar .feed-sidebar-list {
    background: #F1F5F9 !important;
    padding: 14px 12px !important;
    gap: 10px !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-message {
    display: flex !important;
    align-items: flex-end !important;
    gap: 8px !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-message.is-own {
    flex-direction: row-reverse !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-avatar {
    width: 32px !important;
    height: 32px !important;
    font-size: 12px !important;
    border: 0 !important;
    box-shadow: none !important;
    flex-shrink: 0 !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-bubble {
    flex: 0 1 auto !important;
    max-width: 80% !important;
    padding: 9px 13px !important;
    border-radius: 16px 16px 16px 4px !important;
    background: #FFFFFF !important;
    border: 1px solid #E2E8F0 !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-bubble::before {
    display: none !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-author {
    font-size: 12px !important;
    font-weight: 700 !important;
    color: #2563EB !important;
    margin-bottom: 3px !important;
    line-height: 1.2 !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-bubble > div:not(.chat-author):not(.chat-time) {
    font-size: 14px !important;
    line-height: 1.45 !important;
    color: #0F172A !important;
    word-break: break-word !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-time {
    margin-top: 4px !important;
    font-size: 10.5px !important;
    font-weight: 600 !important;
    color: #94A3B8 !important;
    text-align: right !important;
  }

  /* Own message bubble (Blue, right-aligned) */
  body.bt-mob-chat-open .feed-sidebar .chat-message.is-own .chat-bubble {
    border-radius: 16px 16px 4px 16px !important;
    background: #2563EB !important;
    border-color: #2563EB !important;
    color: #FFFFFF !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-message.is-own .chat-author {
    display: none !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-message.is-own .chat-bubble > div:not(.chat-author):not(.chat-time) {
    color: #FFFFFF !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-message.is-own .chat-time {
    color: rgba(255, 255, 255, 0.78) !important;
  }

  /* Sleek Mobile Chat Composer Bar */
  body.bt-mob-chat-open .feed-sidebar .chat-footer {
    padding: 10px 12px calc(10px + var(--bt-mob-safe-bottom)) !important;
    background: #FFFFFF !important;
    border-top: 1px solid #E2E8F0 !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-input-form {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-input {
    flex: 1 !important;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 16px !important;
    border-radius: 999px !important;
    background: #F1F5F9 !important;
    border: 1px solid #E2E8F0 !important;
    font-size: 16px !important;
    box-shadow: none !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-input:focus {
    background: #FFFFFF !important;
    border-color: #2563EB !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-send-btn {
    height: 44px !important;
    min-width: 68px !important;
    padding: 0 16px !important;
    border-radius: 999px !important;
    background: #2563EB !important;
    color: #FFFFFF !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25) !important;
    flex-shrink: 0 !important;
  }

  body.bt-mob-chat-open .feed-sidebar .chat-send-btn:disabled {
    background: #CBD5E1 !important;
    color: #FFFFFF !important;
    opacity: 1 !important;
    box-shadow: none !important;
  }

  /* Hide floating right-side help dock & all Traffic / Auto Extension elements on mobile */
  .feed-help-dock,
  .feed-help-dock.is-visible,
  .feed-extension-helper,
  .feed-extension-queue,
  .feed-circle-action-play,
  .feed-page .feed-main > .feed-score-card,
  .feed-page .feed-main > .feed-composer,
  .feed-page .feed-main > .feed-post-list,
  .feed-page .feed-main > .feed-empty-state,
  #bt-mob-feed-quickbar,
  .bt-mob-inline-ad,
  .bt-center-nav-btn[data-feed-mode="traffic"],
  #bt-ua-sidebar a.bt-ua-sb-item[href="/tasks"],
  body.bt-user-admin-mode .bt-ua-wallet-pill.is-traffic,
  #bt-ua-dashboard-view .bt-ua-kpi-card[data-spa-nav="/tasks"],
  #bt-ua-dashboard-view .bt-saas-activity-list > div:nth-child(2),
  #bt-ua-dashboard-view > .bt-saas-grid-2:last-of-type {
    display: none !important;
  }

  /* Ensure SEO Feed root is always visible on /feed mobile */
  .feed-page .feed-main > #bt-cross-task-root {
    display: grid !important;
  }

  #bt-mob-feed-quickbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border-radius: 16px;
    background: var(--bt-mob-surface);
    border: 1px solid var(--bt-mob-border);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  }

  .bt-mob-qbar-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .bt-mob-qbar-stat {
    padding: 8px 6px;
    border-radius: 11px;
    background: var(--bt-mob-bg);
    text-align: center;
  }

  .bt-mob-qbar-stat span {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--bt-mob-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .bt-mob-qbar-stat strong {
    display: block;
    margin-top: 2px;
    font-size: 17px;
    font-weight: 800;
    color: var(--bt-mob-text);
    font-variant-numeric: tabular-nums;
  }

  .bt-mob-qbar-stat.is-points strong { color: #2563EB; }
  .bt-mob-qbar-stat.is-warn strong { color: #D97706; }
  .bt-mob-qbar-stat.is-session strong { color: #059669; }

  .bt-mob-qbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .bt-mob-create-post-btn {
    flex: 1;
    min-height: 44px;
    padding: 0 16px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563EB, #1D4ED8);
    color: #FFFFFF;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.24);
  }

  .bt-mob-create-post-btn:active {
    transform: scale(0.985);
  }

  .bt-mob-ext-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid var(--bt-mob-border);
    background: var(--bt-mob-bg);
    color: #059669;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
  }

  .bt-mob-ext-btn.is-running {
    background: #FEF2F2;
    border-color: #FECACA;
    color: #DC2626;
  }

  /* Mobile Traffic Post Cards */
  .feed-page .feed-post-card {
    padding: 14px !important;
    border-radius: 16px !important;
    overflow: hidden !important;
  }

  .feed-page .feed-post-head {
    gap: 10px !important;
    margin-bottom: 10px !important;
  }

  .feed-page .feed-post-author {
    min-width: 0 !important;
    gap: 10px !important;
  }

  .feed-page .feed-post-author .feed-avatar {
    width: 38px !important;
    height: 38px !important;
    font-size: 15px !important;
    flex-shrink: 0 !important;
  }

  .feed-page .feed-post-name {
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
  }

  .feed-page .feed-post-meta {
    font-size: 12px !important;
    line-height: 1.3 !important;
  }

  .feed-page .feed-post-content,
  .feed-page .feed-post-comment {
    font-size: 14px !important;
    line-height: 1.5 !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
  }

  /* Task Links -> Large Tap-Friendly Action Buttons (min-height 44px, break-all) */
  .feed-page .feed-post-raw-links {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    margin-top: 8px !important;
  }

  .feed-page .feed-post-raw-line {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
  }

  .feed-page .feed-post-link {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    min-height: 44px !important;
    padding: 10px 12px !important;
    border-radius: 11px !important;
    border: 1px solid #BFDBFE !important;
    background: #EFF6FF !important;
    color: #1D4ED8 !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    text-decoration: none !important;
    word-break: break-all !important;
    overflow-wrap: anywhere !important;
    transition: background 0.15s ease, border-color 0.15s ease;
  }

  .feed-page .feed-post-link::after {
    content: "↗";
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.12);
    color: #1D4ED8;
    font-size: 14px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .feed-page .feed-post-link.bt-link-visited,
  .feed-page .feed-post-link:visited {
    background: #ECFDF5 !important;
    border-color: #A7F3D0 !important;
    color: #047857 !important;
  }

  .feed-page .feed-post-link.bt-link-visited::after {
    content: "✓";
    background: #10B981;
    color: #FFFFFF;
  }

  .feed-page .feed-post-link-suffix {
    margin-left: 2px !important;
    font-size: 12.5px !important;
    color: var(--bt-mob-muted) !important;
    word-break: break-word !important;
  }

  /* Bottom Interaction Bar (Views, Comment, Like) */
  .feed-page .feed-post-toolbar {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin-top: 10px !important;
    padding-top: 10px !important;
  }

  .feed-page .feed-toolbar-btn {
    min-height: 44px !important;
    padding: 0 8px !important;
    border-radius: 10px !important;
    font-size: 13px !important;
    justify-content: center !important;
  }

  .feed-page .feed-comment-box {
    gap: 8px !important;
  }

  .feed-page .feed-comment-input {
    min-height: 44px !important;
    font-size: 16px !important;
  }

  .feed-page .feed-comment-submit {
    min-height: 44px !important;
    min-width: 72px !important;
  }

  /* Lightweight Inline Ad Banner (every 4-5 posts on Mobile) */
  .bt-mob-inline-ad {
    display: flex !important;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 13px;
    border: 1px dashed #CBD5E1;
    background: linear-gradient(135deg, #F8FAFC, #EFF6FF);
    text-decoration: none;
    color: var(--bt-mob-text);
  }

  .bt-mob-inline-ad img {
    width: 56px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
  }

  .bt-mob-inline-ad-copy {
    min-width: 0;
    flex: 1;
  }

  .bt-mob-inline-ad-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    color: #2563EB;
    background: #DBEAFE;
    padding: 1px 6px;
    border-radius: 4px;
    margin-bottom: 2px;
  }

  .bt-mob-inline-ad-copy strong {
    display: block;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .bt-mob-inline-ad-copy span {
    display: block;
    font-size: 11.5px;
    color: var(--bt-mob-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ---- SEO MISSION RUNNER (Step-by-step Mobile Card) ---- */
  #bt-cross-task-root {
    gap: 12px !important;
  }

  .bt-ct-score-card {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
    padding: 10px 8px !important;
    border-radius: 16px !important;
  }

  .bt-ct-score-box {
    padding: 4px 4px !important;
    text-align: center !important;
  }

  .bt-ct-score-label {
    font-size: 11px !important;
  }

  .bt-ct-score-val {
    font-size: 18px !important;
    font-variant-numeric: tabular-nums !important;
  }

  .bt-ct-runner {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    padding: 14px !important;
    border-radius: 16px !important;
  }

  .bt-ct-runner-topmeta {
    order: 1;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
  }

  #bt-ct-skip-task {
    min-height: 38px !important;
    padding: 0 12px !important;
    border-radius: 10px !important;
    font-size: 12.5px !important;
    white-space: nowrap !important;
  }

  .bt-ct-runner-heading {
    order: 2;
    font-size: 16px !important;
    margin: 0 !important;
  }

  /* Steps appear cleanly BEFORE the bottom verify bar on mobile */
  .bt-ct-runner .bt-ct-clean-steps {
    order: 3;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  .bt-ct-clean-step {
    padding: 12px !important;
    border-radius: 12px !important;
    border: 1px solid #E2E8F0 !important;
    background: #F8FAFC !important;
  }

  /* Step 1: Highlighted Keyword + Large 44px COPY button on right */
  .bt-ct-clean-step-line {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .bt-ct-kw-chip {
    flex: 1 1 auto !important;
    min-height: 44px !important;
    padding: 8px 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    border-radius: 10px !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    word-break: break-word !important;
  }

  .bt-ct-copy-pill {
    min-height: 44px !important;
    min-width: 82px !important;
    padding: 0 16px !important;
    border-radius: 10px !important;
    font-size: 13.5px !important;
    font-weight: 800 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }

  /* Step 2/3 Guide Image: 100% width, tappable zoom */
  .bt-ct-guide-img-block {
    margin-top: 10px !important;
  }

  .bt-ct-guide-img-frame {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    position: relative !important;
  }

  .bt-ct-guide-img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 380px !important;
    object-fit: contain !important;
    display: block !important;
  }

  /* Sticky / Prominent Code Verification Bar directly below Steps */
  .bt-ct-runner .bt-ct-verify-top-form {
    order: 4;
    position: sticky !important;
    bottom: calc(var(--bt-mob-bottom-h) + var(--bt-mob-safe-bottom) + 6px) !important;
    z-index: 25 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding: 12px !important;
    margin: 4px -4px 0 !important;
    border-radius: 14px !important;
    background: rgba(255, 255, 255, 0.97) !important;
    border: 1px solid #BFDBFE !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12) !important;
  }

  .bt-ct-verify-top-input {
    width: 100% !important;
    min-height: 48px !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    letter-spacing: 0.08em !important;
    text-align: center !important;
    border-radius: 11px !important;
  }

  .bt-ct-verify-top-btn {
    width: 100% !important;
    min-height: 48px !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    border-radius: 11px !important;
    background: #2563EB !important;
    color: #FFFFFF !important;
  }

  /* ==========================================================================
   * 3. USER DASHBOARD (/dashboard, /tasks) & ADMIN PANEL (/admin) SHELL
   * ========================================================================== */

  /* Compact 56px Mobile Header for User Admin & Enterprise Admin */
  body.bt-user-admin-mode #bt-ua-header,
  body.bt-adm-ent-mode #bt-ae-header {
    height: var(--bt-mob-header-h) !important;
    min-height: var(--bt-mob-header-h) !important;
    padding: 0 12px !important;
    left: 0 !important;
    z-index: 1160 !important;
  }

  body.bt-user-admin-mode .app-page:not(.admin-page) {
    padding: calc(var(--bt-mob-header-h) + 12px) 12px calc(var(--bt-mob-bottom-h) + var(--bt-mob-safe-bottom) + 20px) 12px !important;
  }

  body.bt-adm-ent-mode .admin-page,
  body.bt-adm-ent-mode.bt-ae-collapsed .admin-page {
    padding: calc(var(--bt-mob-header-h) + 12px) 12px calc(var(--bt-mob-bottom-h) + var(--bt-mob-safe-bottom) + 20px) 12px !important;
  }

  .bt-ua-menu-toggle,
  .ae-mobile-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
  }

  .bt-ua-header-left,
  .ae-header-left {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    gap: 8px !important;
  }

  .bt-ua-header-right,
  .ae-header-right {
    flex-shrink: 0 !important;
    gap: 6px !important;
  }

  .bt-ua-page-heading,
  .ae-header-title {
    font-size: 14.5px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Keep SEO wallet pill visible on User Admin mobile (Traffic wallet hidden) */
  body.bt-user-admin-mode .bt-ua-wallet-group {
    display: flex !important;
    gap: 4px !important;
  }

  body.bt-user-admin-mode .bt-ua-wallet-pill.is-seo {
    display: inline-flex !important;
    height: 32px !important;
    padding: 0 8px !important;
    font-size: 11.5px !important;
    gap: 3px !important;
  }

  body.bt-user-admin-mode .bt-ua-wallet-pill.is-seo span,
  body.bt-user-admin-mode .bt-ua-wallet-pill.is-seo svg {
    display: none !important;
  }

  body.bt-user-admin-mode .bt-ua-wallet-pill.is-seo::before {
    content: "SEO:";
    font-weight: 800;
    color: #0D9488;
  }

  body.bt-user-admin-mode .bt-ua-cta-btn {
    min-height: 36px !important;
    padding: 0 9px !important;
    font-size: 12px !important;
    gap: 4px !important;
  }

  body.bt-user-admin-mode .bt-ua-cta-btn span {
    display: none !important;
  }

  body.bt-user-admin-mode .bt-ua-cta-btn::after {
    content: "Tạo SEO";
    font-weight: 700;
  }

  /* Sidebar drawers stop cleanly above bottom nav or sit above it */
  #bt-ua-sidebar,
  #bt-ae-sidebar {
    z-index: 1350 !important;
    padding-bottom: calc(16px + var(--bt-mob-safe-bottom)) !important;
  }

  #bt-ua-backdrop,
  #bt-ae-backdrop {
    z-index: 1340 !important;
  }

  /* KPI Grids: Always 2 Columns on Tablet & Mobile with Tabular Numerals & Zero Overflow */
  .bt-ua-kpi-grid,
  .ae-kpi-grid-6,
  .ae-kpi-grid-4,
  body.bt-adm-ent-mode #bt-autopost-panel .bt-metrics-grid,
  body.bt-adm-ent-mode #bt-autopost-panel .bt-bots-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .bt-ua-kpi-card,
  .ae-kpi-card {
    position: relative !important;
    display: block !important;
    padding: 12px !important;
    border-radius: 14px !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }

  .bt-ua-kpi-card > div:first-child,
  .ae-kpi-card > div:first-child {
    min-width: 0 !important;
    width: 100% !important;
  }

  .bt-ua-kpi-label,
  .ae-kpi-label {
    font-size: 11.5px !important;
    line-height: 1.3 !important;
    padding-right: 32px !important;
    min-height: 28px !important;
  }

  .bt-ua-kpi-val,
  .ae-kpi-val {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: baseline !important;
    gap: 2px !important;
    font-size: clamp(14px, 4.1vw, 19px) !important;
    line-height: 1.25 !important;
    margin-top: 4px !important;
    font-variant-numeric: tabular-nums !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    max-width: 100% !important;
  }

  .bt-ua-kpi-val span {
    font-size: inherit !important;
  }

  .bt-ua-kpi-sub,
  .ae-kpi-sub {
    font-size: 11px !important;
    line-height: 1.3 !important;
    margin-top: 4px !important;
  }

  .bt-ua-kpi-icon {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    width: 28px !important;
    height: 28px !important;
    border-radius: 8px !important;
    flex-shrink: 0 !important;
  }

  .bt-ua-kpi-icon svg {
    width: 15px !important;
    height: 15px !important;
  }

  /* Prevent CSS Grid minmax(auto, 1fr) horizontal blow-out across all mobile views */
  .app-page,
  .app-container,
  .admin-page,
  .bt-saas-view,
  #bt-user-seo-admin-panel,
  #bt-ua-dashboard-view,
  #bt-adm-ent-stage,
  #bt-cross-task-root {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .bt-saas-view,
  #bt-user-seo-admin-panel,
  #bt-ua-dashboard-view,
  #bt-adm-ent-stage,
  #bt-cross-task-root {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .bt-saas-view > *,
  #bt-user-seo-admin-panel > *,
  #bt-ua-dashboard-view > *,
  #bt-adm-ent-stage > *,
  #bt-cross-task-root > * {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Project Selector Bar & Active Project Banner */
  .bt-proj-bar {
    padding: 10px !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  .bt-proj-pills {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 100% !important;
  }

  .bt-proj-pills::-webkit-scrollbar {
    display: none;
  }

  .bt-proj-pill {
    min-height: 40px !important;
    flex-shrink: 0 !important;
  }

  #bt-proj-open-create {
    width: 100%;
    min-height: 44px !important;
    justify-content: center;
  }

  .bt-proj-banner {
    padding: 12px !important;
    gap: 10px !important;
  }

  .bt-proj-banner > div:last-child {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr auto;
    gap: 8px !important;
  }

  .bt-proj-banner .bt-saas-btn {
    min-height: 44px !important;
    justify-content: center;
  }
}

/* ==========================================================================
 * 4. MOBILE DATA TABLES -> SMART CARD VIEW + ACTION SHEET (< 768px)
 * ========================================================================== */
@media (max-width: 767.98px) {
  /* ---- GLOBAL TOUCH TARGETS & iOS NO-ZOOM INPUTS ---- */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="url"],
  input[type="tel"],
  select,
  textarea {
    font-size: 16px !important;
  }

  .bt-saas-btn,
  .bt-ct-btn,
  .ae-btn,
  .ae-pill,
  .bt-ua-filter-pill,
  .bt-more-btn,
  .ae-more-btn {
    min-height: 44px !important;
  }

  .bt-more-btn,
  .ae-more-btn {
    min-width: 44px !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 10px !important;
    font-size: 18px !important;
  }

  /* ---- DATA TABLES -> VERTICAL MOBILE CARDS ---- */
  .bt-saas-table-wrap,
  .ae-table-wrap {
    overflow: visible !important;
    background: transparent !important;
  }

  .bt-saas-card:has(.bt-saas-table),
  .ae-card:has(.ae-table) {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .bt-saas-card:has(.bt-saas-table) .bt-saas-card-head {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 14px;
    margin-bottom: 10px;
    padding: 12px 14px;
  }

  .bt-saas-table,
  .bt-saas-table tbody,
  .ae-table,
  .ae-table tbody {
    display: block !important;
    width: 100% !important;
  }

  .bt-saas-table thead,
  .ae-table thead {
    display: none !important;
  }

  .bt-saas-table tbody tr,
  .ae-table tbody tr {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    margin-bottom: 10px !important;
    padding: 14px !important;
    border-radius: 14px !important;
    border: 1px solid #E2E8F0 !important;
    background: #FFFFFF !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04) !important;
  }

  /* Empty / loading rows stay centered */
  .bt-saas-table tbody tr:has(td[colspan]),
  .ae-table tbody tr:has(td[colspan]) {
    text-align: center !important;
    align-items: center !important;
  }

  .bt-saas-table tbody td,
  .ae-table tbody td {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 4px !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 0 !important;
    border: 0 !important;
    text-align: left !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  /* Subtle field label injected from thead th via mobile-responsive.js */
  .bt-saas-table tbody td[data-mob-label]:not([data-mob-label=""]):not(.bt-mob-td-actions):not(:first-child)::before,
  .ae-table tbody td[data-mob-label]:not([data-mob-label=""]):not(.bt-mob-td-actions):not(:first-child)::before {
    content: attr(data-mob-label);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94A3B8;
  }

  /* Card Header Emphasis (First Cell) */
  .bt-saas-table tbody td:first-child,
  .ae-table tbody td:first-child {
    padding-bottom: 8px !important;
    border-bottom: 1px solid #F1F5F9 !important;
  }

  /* Card Actions Footer (Last Cell when containing .bt-row-actions or .ae-row-actions) */
  .bt-saas-table tbody td:has(.bt-row-actions),
  .ae-table tbody td:has(.ae-row-actions),
  .bt-saas-table tbody td.bt-mob-td-actions,
  .ae-table tbody td.bt-mob-td-actions {
    margin-top: 4px !important;
    padding-top: 10px !important;
    border-top: 1px solid #F1F5F9 !important;
  }

  .bt-row-actions,
  .ae-row-actions {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    justify-content: flex-start !important;
  }

  .bt-row-actions > .bt-saas-btn,
  .ae-row-actions > .ae-btn {
    flex: 1 1 0 !important;
    justify-content: center !important;
    padding: 0 10px !important;
    font-size: 13px !important;
  }

  .bt-row-actions > .bt-more-wrap,
  .ae-row-actions > .ae-more-btn {
    flex-shrink: 0 !important;
  }

  /* Pagination bar inside cardless table container */
  .ae-pagination {
    background: #FFFFFF !important;
    border: 1px solid #E2E8F0 !important;
    border-radius: 14px !important;
    padding: 12px 14px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    text-align: center !important;
  }

  .ae-pagination > div {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  /* Native /tasks Traffic Post Cards */
  .tasks-card {
    padding: 14px !important;
    border-radius: 14px !important;
  }

  .tasks-card-head {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }

  .tasks-card-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .tasks-card-actions > button,
  .tasks-card-actions > a {
    flex: 1 1 auto !important;
    min-height: 44px !important;
    justify-content: center !important;
  }

  /* ---- BOTTOM ACTION SHEET FOR "•••" MENUS (Prevents Accidental Delete) ---- */
  #bt-mob-actionsheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2490;
    background: rgba(15, 23, 42, 0.48);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }

  body.bt-mob-sheet-open #bt-mob-actionsheet-backdrop {
    display: block;
  }

  .bt-more-menu.is-open,
  .ae-more-menu.is-open {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    z-index: 2500 !important;
    border-radius: 20px 20px 0 0 !important;
    border: 0 !important;
    padding: 10px 14px calc(16px + var(--bt-mob-safe-bottom)) !important;
    background: #FFFFFF !important;
    box-shadow: 0 -14px 40px rgba(15, 23, 42, 0.24) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    animation: btMobSheetUp 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .bt-more-menu.is-open::before,
  .ae-more-menu.is-open::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: #CBD5E1;
    margin: 0 auto 8px;
  }

  .bt-more-menu.is-open button,
  .ae-more-menu.is-open button {
    width: 100% !important;
    min-height: 48px !important;
    padding: 0 16px !important;
    border-radius: 12px !important;
    background: #F8FAFC !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    text-align: center !important;
    justify-content: center !important;
  }

  .bt-more-menu.is-open button.is-danger,
  .ae-more-menu.is-open button.is-danger {
    margin-top: 6px !important;
    background: #FEF2F2 !important;
    color: #DC2626 !important;
    border: 1px solid #FECACA !important;
  }

  .bt-mob-sheet-cancel {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    margin-top: 6px;
    border: 1px solid #E2E8F0 !important;
    border-radius: 12px !important;
    background: #FFFFFF !important;
    color: #475569 !important;
    font-size: 15px !important;
    font-weight: 700 !important;
  }

  /* ---- COLLAPSIBLE MOBILE FILTER BAR -> BOTTOM DRAWER ---- */
  .bt-ua-toolbar,
  .ae-toolbar {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 10px !important;
    border-radius: 14px !important;
  }

  .bt-ua-toolbar-left,
  .ae-toolbar-group {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .bt-ua-search-wrap,
  .ae-search-box {
    flex: 1 1 180px !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  .bt-ua-search-input,
  .ae-search-box .ae-input {
    min-height: 44px !important;
    width: 100% !important;
  }

  .bt-mob-filter-bar-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid #CBD5E1;
    background: #FFFFFF;
    color: #0F172A;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
  }

  .bt-mob-filter-bar-btn.has-active {
    border-color: #2563EB;
    background: #EFF6FF;
    color: #1D4ED8;
  }

  /* Collapse secondary filter pills/selects cleanly behind toggle */
  .bt-ua-toolbar:not(.is-mob-filters-open) .bt-ua-filter-pills,
  .ae-toolbar:not(.is-mob-filters-open) .ae-pills,
  .ae-toolbar:not(.is-mob-filters-open) .ae-select {
    display: none !important;
  }

  .bt-ua-toolbar.is-mob-filters-open .bt-ua-filter-pills,
  .ae-toolbar.is-mob-filters-open .ae-pills {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
    padding-top: 6px;
    border-top: 1px solid #F1F5F9;
  }

  .ae-toolbar.is-mob-filters-open .ae-select {
    display: block !important;
    width: 100% !important;
    min-height: 44px !important;
  }

  /* Audit log rows on Mobile */
  .ae-audit-row,
  .ae-log-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
    padding: 12px !important;
  }
}

/* ==========================================================================
 * 5. FULL-SCREEN MODALS & BOTTOM DRAWERS ON MOBILE (< 640px)
 * ========================================================================== */
@media (max-width: 639.98px) {
  .bt-ct-modal-backdrop,
  .ae-modal-backdrop,
  .feed-modal-backdrop,
  .tasks-modal-backdrop {
    padding: 0 !important;
    align-items: flex-end !important;
  }

  .bt-ct-modal,
  .ae-modal,
  .feed-modal-card,
  .tasks-modal-card {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92dvh !important;
    border-radius: 20px 20px 0 0 !important;
    margin: 0 !important;
    padding: 16px 14px calc(20px + var(--bt-mob-safe-bottom)) !important;
    overflow-y: auto !important;
    animation: btMobSheetUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .ae-drawer-backdrop {
    padding: 0 !important;
  }

  .ae-drawer {
    width: 100% !important;
    max-width: 100% !important;
    height: 100dvh !important;
    border-radius: 0 !important;
  }

  .bt-ct-form-row-2,
  .ae-field-row,
  .feed-modal-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .bt-ct-modal-close,
  .ae-modal-close,
  .feed-modal-close,
  .tasks-modal-close {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
  }

  /* Toast sits cleanly above the Bottom Navigation Bar */
  .bt-ct-toast,
  .feed-toast {
    bottom: calc(var(--bt-mob-bottom-h) + var(--bt-mob-safe-bottom) + 12px) !important;
    left: 12px !important;
    right: 12px !important;
    max-width: none !important;
    transform: none !important;
  }

  /* Dual wallet pill slightly tighter on narrow 360px phones */
  #bt-mob-feed-wallet-pill {
    padding: 0 8px;
    font-size: 11px;
    gap: 4px;
  }

  .feed-page .feed-brand {
    font-size: 13.5px !important;
  }
}

/* ==========================================================================
 * 6. DARK MODE SUPPORT FOR FEED MOBILE SHELL (.feed-page.is-dark)
 * ========================================================================== */
@media (max-width: 1024px) {
  body.bt-feed-dark .feed-page .feed-shell-topbar {
    background: rgba(10, 17, 31, 0.96) !important;
    border-bottom-color: #24324A !important;
  }

  body.bt-feed-dark #bt-mob-feed-wallet-pill {
    background: #172338;
    border-color: #293954;
    color: #E2E8F0;
  }

  body.bt-feed-dark #bt-mob-feed-wallet-pill .bt-mw-t { color: #60A5FA; }
  body.bt-feed-dark #bt-mob-feed-wallet-pill .bt-mw-s { color: #2DD4BF; }

  body.bt-feed-dark #bt-mob-feed-drawer-btn,
  body.bt-feed-dark .bt-mob-chat-close-btn {
    background: #172338;
    border-color: #293954;
    color: #E2E8F0;
  }

  body.bt-feed-dark #bt-mob-bottom-nav {
    background: rgba(15, 23, 42, 0.96);
    border-top-color: #24324A;
    box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.35);
  }

  body.bt-feed-dark .bt-mob-nav-item {
    color: #94A3B8;
  }

  body.bt-feed-dark .bt-mob-nav-item.is-active {
    color: #60A5FA;
  }

  body.bt-feed-dark .bt-mob-nav-item.is-active.is-seo {
    color: #2DD4BF;
  }

  body.bt-feed-dark #bt-mob-drawer {
    background: #0F172A;
    color: #F1F5F9;
  }

  body.bt-feed-dark .bt-mob-drawer-head,
  body.bt-feed-dark .bt-mob-chat-sheet-bar {
    background: #0F172A;
    border-color: #24324A;
  }

  body.bt-feed-dark .bt-mob-chat-sheet-title strong {
    color: #F8FAFC;
  }

  body.bt-feed-dark .bt-mob-chat-icon {
    background: #1E293B;
    color: #60A5FA;
  }

  body.bt-feed-dark.bt-mob-chat-open .feed-page .feed-sidebar {
    background: #0F172A !important;
  }

  body.bt-feed-dark.bt-mob-chat-open .feed-sidebar .feed-sidebar-list {
    background: #0B1220 !important;
  }

  body.bt-feed-dark.bt-mob-chat-open .feed-sidebar .chat-bubble {
    background: #172338 !important;
    border-color: #24324A !important;
  }

  body.bt-feed-dark.bt-mob-chat-open .feed-sidebar .chat-author {
    color: #60A5FA !important;
  }

  body.bt-feed-dark.bt-mob-chat-open .feed-sidebar .chat-bubble > div:not(.chat-author):not(.chat-time) {
    color: #E2E8F0 !important;
  }

  body.bt-feed-dark.bt-mob-chat-open .feed-sidebar .chat-message.is-own .chat-bubble {
    background: #2563EB !important;
    border-color: #2563EB !important;
  }

  body.bt-feed-dark.bt-mob-chat-open .feed-sidebar .chat-footer {
    background: #0F172A !important;
    border-color: #24324A !important;
  }

  body.bt-feed-dark.bt-mob-chat-open .feed-sidebar .chat-input {
    background: #172338 !important;
    border-color: #293954 !important;
    color: #F1F5F9 !important;
  }

  body.bt-feed-dark.bt-mob-chat-open .feed-sidebar .chat-send-btn:disabled {
    background: #334155 !important;
    color: #94A3B8 !important;
  }

  body.bt-feed-dark .bt-mob-drawer-brand,
  body.bt-feed-dark .bt-mob-drawer-user strong,
  body.bt-feed-dark .bt-mob-drawer-btn {
    color: #F1F5F9;
  }

  body.bt-feed-dark .bt-mob-drawer-close,
  body.bt-feed-dark .bt-mob-drawer-profile,
  body.bt-feed-dark .bt-mob-drawer-wcard {
    background: #172338;
    border-color: #293954;
    color: #F1F5F9;
  }

  body.bt-feed-dark #bt-mob-feed-quickbar {
    background: #111A2B;
    border-color: #24324A;
  }

  body.bt-feed-dark .bt-mob-qbar-stat {
    background: #182338;
  }

  body.bt-feed-dark .bt-mob-qbar-stat strong {
    color: #F1F5F9;
  }

  body.bt-feed-dark .bt-mob-qbar-stat.is-points strong { color: #60A5FA; }
  body.bt-feed-dark .bt-mob-qbar-stat.is-warn strong { color: #FBBF24; }
  body.bt-feed-dark .bt-mob-qbar-stat.is-session strong { color: #34D399; }

  body.bt-feed-dark .bt-mob-ext-btn {
    background: #182338;
    border-color: #293954;
    color: #34D399;
  }

  body.bt-feed-dark .feed-page .feed-post-link {
    background: #16243D !important;
    border-color: #263E66 !important;
    color: #93C5FD !important;
  }

  body.bt-feed-dark .feed-page .feed-post-link::after {
    background: rgba(96, 165, 250, 0.16);
    color: #93C5FD;
  }

  body.bt-feed-dark .feed-page .feed-post-link.bt-link-visited {
    background: #0F2D27 !important;
    border-color: #1A5C4D !important;
    color: #6EE7B7 !important;
  }

  body.bt-feed-dark .bt-mob-inline-ad {
    background: #162135;
    border-color: #293954;
    color: #F1F5F9;
  }

  body.bt-feed-dark .bt-ct-clean-step {
    background: #162135 !important;
    border-color: #293954 !important;
  }

  body.bt-feed-dark .bt-ct-runner .bt-ct-verify-top-form {
    background: rgba(17, 26, 43, 0.97) !important;
    border-color: #293954 !important;
  }
}

@keyframes btMobSheetUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
