/* ==========================================================
   CRUXLISTING — SMARTPHONE FIRST DESIGN
   Separate layer. Existing desktop and backend remain intact.
   ========================================================== */

@media (max-width: 700px) {

  :root {
    --mobile-ink: #14243b;
    --mobile-muted: #718096;
    --mobile-brand: #0969ff;
    --mobile-border: #e7edf5;
    --mobile-surface: #ffffff;
    --mobile-bg: #f5f7fb;
  }

  html {
    scroll-behavior: smooth;
    scroll-padding-top: 90px;
  }

  body {
    background: var(--mobile-bg);
    color: var(--mobile-ink);
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
    -webkit-tap-highlight-color: transparent;
  }

  button, input, select, textarea, a {
    -webkit-tap-highlight-color: transparent;
  }

  /* Header */
  .site-header {
    position: sticky;
    top: 0;
    z-index: 80;
    background: rgba(255,255,255,.97);
    border-bottom: 1px solid var(--mobile-border);
    box-shadow: 0 2px 12px rgba(20,35,60,.045);
    height: auto;
  }

  .site-header .header-inner {
    min-height: 58px;
    height: auto;
    padding: 9px 15px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  .logo {
    height: 32px;
    width: auto;
    object-fit: contain;
  }

  .header-actions {
    margin-left: auto;
    gap: 8px;
    align-items: center;
  }

  .header-actions .btn {
    min-height: 38px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 13px;
    white-space: nowrap;
  }

  .header-actions .free-badge {
    display: none;
  }

  .user-menu-name {
    display: none;
  }

  .user-menu-trigger {
    min-height: 38px;
    padding: 4px;
  }

  /* Keep the global search useful on internal pages.
     Homepage already has its larger dedicated search. */
  .site-header .search-form {
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    max-width: none;
    margin: 2px 0 0;
  }

  body:has(.hero) .site-header .search-form {
    display: none;
  }

  .site-header .search-input {
    width: 100%;
    height: 42px;
    border: 1px solid var(--mobile-border);
    border-radius: 12px;
    background: #f4f7fc;
    font-size: 16px;
    padding: 0 13px;
  }

  /* Homepage hero */
  body:has(.hero) .hero {
    min-height: 0;
    padding: 0;
    background: linear-gradient(145deg, #edf5ff 0%, #f8fbff 58%, #ffffff 100%);
    color: var(--mobile-ink);
    border-bottom: 1px solid #e6eef9;
  }

  .hero-inner {
    width: 100%;
    padding: 23px 16px 18px;
  }

  .hero-content {
    width: 100%;
    max-width: none;
  }

  .hero h1 {
    max-width: 340px;
    margin: 0 0 9px;
    color: #14243b;
    font-size: clamp(27px, 7.5vw, 34px);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -1.1px;
  }

  .hero h1 span {
    color: var(--mobile-brand);
  }

  .hero .hero-subtitle {
    margin: 0 0 17px;
    color: #61718a;
    font-size: 13px;
    line-height: 1.5;
  }

  /* Thumb-friendly search panel */
  .search-box {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    width: 100%;
    padding: 10px;
    border: 1px solid #e4ebf5;
    border-radius: 17px;
    background: #fff;
    box-shadow: 0 8px 28px rgba(31,65,110,.09);
  }

  .search-field {
    display: flex;
    align-items: center;
    min-width: 0;
    height: 48px;
    padding: 0 13px;
    border: 1px solid #e8edf4;
    border-radius: 11px;
    background: #f8fafd;
    gap: 10px;
  }

  .search-field > span {
    flex: 0 0 auto;
    color: #718096;
    font-size: 16px;
  }

  .search-field input {
    width: 100%;
    min-width: 0;
    height: 46px;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--mobile-ink);
    font-size: 16px;
  }

  .search-field input::placeholder {
    color: #8995a7;
    opacity: 1;
  }

  .search-button {
    width: 100%;
    height: 49px;
    border: 0;
    border-radius: 11px;
    background: var(--mobile-brand);
    color: #fff;
    font-size: 16px;
    font-weight: 750;
    box-shadow: 0 4px 12px rgba(9,105,255,.2);
  }

  .popular-searches {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    margin-top: 13px;
    color: #a0aabd;
    font-size: 0;
  }

  .popular-searches a {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 11px;
    border: 1px solid #e1eaf7;
    border-radius: 30px;
    background: rgba(255,255,255,.8);
    color: #45617f;
    font-size: 12px;
    font-weight: 650;
    text-decoration: none;
  }

  /* Category grid */
  .category-nav {
    padding: 8px 0 12px;
    background: #fff;
    border-bottom: 1px solid var(--mobile-border);
  }

  .category-nav .container {
    padding: 0 12px;
  }

  .category-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 8px;
    padding: 5px 0;
  }

  .category-item {
    display: flex;
    min-width: 0;
    min-height: 78px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 3px;
    border: 1px solid #edf1f7;
    border-radius: 13px;
    background: #fff;
    color: #34445b;
    text-align: center;
    text-decoration: none;
    transition: background .15s ease, border-color .15s ease;
  }

  .category-icon {
    display: grid;
    place-items: center;
    width: 35px;
    height: 35px;
    margin: 0;
    border-radius: 11px;
    background: #edf5ff !important;
    color: var(--mobile-brand);
    font-size: 21px;
  }

  .category-name {
    max-width: 100%;
    color: #40516a;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  /* Homepage content spacing */
  body:has(.hero) main > .container {
    padding-right: 13px;
    padding-left: 13px;
  }

  .section {
    margin: 22px 0 27px;
  }

  .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
  }

  .section-title {
    margin: 0;
    color: #172840;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -.35px;
  }

  .section-title-icon {
    font-size: 17px;
  }

  .section-link {
    flex: 0 0 auto;
    color: var(--mobile-brand);
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
  }

  /* Fresh listing cards */
  .fresh-grid,
  .vehicle-grid,
  .pet-grid,
  .marketplace-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 10px;
  }

  .fresh-grid .card,
  .vehicle-card,
  .property-card,
  .pet-card,
  .market-item {
    min-width: 0;
    overflow: hidden;
    border: 1px solid #e8edf4;
    border-radius: 13px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(20,35,60,.035);
  }

  .fresh-grid .card {
    display: block;
    color: inherit;
    text-decoration: none;
  }

  .fresh-grid .card .card-image,
  .vehicle-image,
  .property-image,
  .pet-image,
  .market-image {
    position: relative;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #edf1f6;
  }

  .fresh-grid .card .card-image img,
  .vehicle-image img,
  .property-image img,
  .pet-image img,
  .market-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .fresh-grid .card-body,
  .vehicle-body,
  .property-body,
  .pet-body {
    min-width: 0;
    padding: 9px 10px 11px;
  }

  .fresh-grid .price,
  .vehicle-card .price,
  .property-card .price,
  .pet-card .price,
  .market-item .price {
    display: block;
    margin: 0 0 4px;
    color: #0969ff;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.25;
  }

  .fresh-grid .card-title,
  .vehicle-card .card-title,
  .property-card .card-title,
  .pet-card .card-title {
    display: -webkit-box;
    min-height: 34px;
    margin: 0 0 6px;
    overflow: hidden;
    color: #25364d;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .fresh-grid .meta,
  .vehicle-card .meta,
  .property-card .meta,
  .pet-card .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 5px;
    color: #8490a1;
    font-size: 10px;
    line-height: 1.35;
  }

  .favorite {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(220,228,239,.9);
    border-radius: 50%;
    background: rgba(255,255,255,.95);
    color: #53647b;
    font-size: 19px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
  }

  .favorite.active {
    color: #e54867;
  }

  /* Category-specific cards */
  .real-estate-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 11px;
  }

  .property-card {
    display: grid;
    grid-template-columns: 42% minmax(0,1fr);
    align-items: stretch;
  }

  .property-image {
    height: 100%;
    min-height: 132px;
    aspect-ratio: auto;
  }

  .property-body {
    align-self: center;
  }

  .jobs-list {
    display: grid;
    gap: 9px;
  }

  .job-card {
    min-width: 0;
    padding: 13px;
    border: 1px solid #e8edf4;
    border-radius: 13px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(20,35,60,.035);
  }

  .job-card-info {
    min-width: 0;
  }

  .job-card-info h3,
  .job-card-title {
    font-size: 14px;
    line-height: 1.35;
  }

  .marketplace-grid .market-item {
    display: block;
  }

  /* Bottom navigation */
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    min-height: 62px;
    padding: 6px 5px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid #e6ebf2;
    background: rgba(255,255,255,.98);
    box-shadow: 0 -5px 22px rgba(25,45,75,.08);
    backdrop-filter: blur(14px);
  }

  .bn-item {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 10px;
    color: #8490a1;
    font-size: 10px;
    font-weight: 650;
    text-decoration: none;
  }

  .bn-item svg {
    width: 21px;
    height: 21px;
  }

  .bn-item.active {
    color: var(--mobile-brand);
  }

  .bn-post {
    color: #fff !important;
  }

  .bn-post svg {
    box-sizing: content-box;
    width: 23px;
    height: 23px;
    padding: 7px;
    margin-top: -17px;
    border: 4px solid #fff;
    border-radius: 17px;
    background: var(--mobile-brand);
    color: #fff;
    box-shadow: 0 3px 10px rgba(9,105,255,.25);
  }

  .bn-post span {
    margin-top: 0;
    color: var(--mobile-brand);
  }

  /* Homepage CTA and trust */
  .cta-wrap {
    margin: 25px 0 20px;
  }

  .post-cta {
    padding: 21px 17px;
    border-radius: 17px;
    background: linear-gradient(135deg,#102c50,#0969ff);
    color: #fff;
  }

  .post-cta h2,
  .cta-title {
    color: #fff;
    font-size: 20px;
    line-height: 1.2;
  }

  .cta-text {
    color: #dbe9ff;
    font-size: 13px;
  }

  .trust-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    margin-top: 12px;
  }

  .trust-item {
    padding: 12px;
    border: 1px solid #e8edf4;
    border-radius: 12px;
    background: #fff;
  }

  /* Avoid narrow-screen overflow */
  img, video, iframe {
    max-width: 100%;
  }

  input, select, textarea, button {
    max-width: 100%;
  }

  .container {
    max-width: 100%;
  }
}

/* Small phones */
@media (max-width: 380px) {
  .hero-inner {
    padding-right: 13px;
    padding-left: 13px;
  }

  .hero h1 {
    font-size: 26px;
  }

  .fresh-grid,
  .vehicle-grid,
  .pet-grid,
  .marketplace-grid {
    gap: 7px;
  }

  .fresh-grid .card-body,
  .vehicle-body,
  .property-body,
  .pet-body {
    padding: 8px;
  }

  .fresh-grid .price,
  .vehicle-card .price,
  .property-card .price,
  .pet-card .price {
    font-size: 14px;
  }
}
