/* =========================================================
   JaraFund — mobile overrides
   Loaded last. Wins by cascade order (no !important needed).
   Only applies at <= 860px so desktop/tablet keep current design.
========================================================= */

@media (max-width: 860px) {

  /* --- Safe areas (notch + gesture bar) --- */
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-topbar {
    padding-top: calc(12px + env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .app-shell {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  /* --- Kill horizontal overflow --- */
  body, .app-layout, .app-main {
    overflow-x: hidden;
    width: 100%;
  }

  /* --- Breathing room --- */
  .app-main {
    padding: 0 16px;
  }

  .feed-header {
    padding: 16px 0;
  }

  .feed-header h1 {
    font-size: 24px;
    line-height: 1.2;
  }

  .feed-tagline {
    font-size: 14px;
  }

  /* --- Feed grid: single column on phones --- */
  .feed-grid,
  .campaign-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 0 0 32px;
  }

  /* --- Cards: less internal padding so more content fits --- */
  .feed-card {
    border-radius: 14px;
  }

  /* --- Touch targets: min 44px for accessibility --- */
  .btn,
  .bottom-nav-item,
  .sidebar-link,
  .reaction-btn,
  .wallet-action-btn {
    min-height: 44px;
  }

  .btn-sm {
    min-height: 36px;
    padding: 8px 14px;
  }

  /* --- Form controls: 16px font stops iOS/Android zoom on focus --- */
  input,
  textarea,
  select {
    font-size: 16px;
    min-height: 44px;
    padding: 12px 14px;
  }

  textarea {
    min-height: 96px;
  }

  /* --- Modals: full-screen on phones --- */
  .modal-overlay,
  #donateModal,
  #reportModal {
    padding: 0;
    align-items: stretch;
  }

  .modal-overlay .auth-card,
  #donateModal .auth-card,
  #reportModal .auth-card {
    max-width: none;
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  /* --- Wallet card: stack stats vertically --- */
  .wallet-card-stats {
    flex-direction: column;
    gap: 10px;
  }

  /* --- Wallet actions: side by side but taller --- */
  .wallet-actions {
    gap: 10px;
  }

  .wallet-action-btn {
    padding: 18px 10px;
  }

  /* --- Profile header: stack on phones --- */
  .profile-header {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }

  .profile-meta {
    justify-content: center;
  }

  /* --- Data tables: allow horizontal scroll instead of squishing --- */
  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  /* --- Category row: horizontal scroll on phones --- */
  .category-row {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .category-row::-webkit-scrollbar {
    display: none;
  }

  /* --- Kill hover effects on touch devices --- */
  @media (hover: none) {
    .btn:hover,
    .feed-card:hover,
    .wallet-action-btn:hover,
    .reaction-btn:hover {
      transform: none;
    }
  }

  /* --- Larger "close" taps on modals --- */
  .modal-overlay button[aria-label*="close" i],
  .modal-overlay .close-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

/* --- Very small phones (iPhone SE, older Android) --- */
@media (max-width: 380px) {
  .app-main {
    padding: 0 12px;
  }

  .feed-header h1 {
    font-size: 22px;
  }

  .bottom-nav-item {
    font-size: 9px;
  }
}