:root{
  --bg:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --line:#e2e8f0;
  --card:#ffffff;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  --primary:#2563eb;
  --primary2:#1d4ed8;
  --chip:#f1f5f9;
}

*{box-sizing:border-box}
html,body{margin:0;padding:0;font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;}
body{background:var(--bg);color:var(--text);}
a{color:inherit;text-decoration:none}
.container{width:min(1100px, 92vw);margin:0 auto}
.muted{color:var(--muted)}
.fine{font-size:12px}
.hidden{display:none}

/* ===== topbar (slightly stronger branding) ===== */
.topbar{
  position:sticky;top:0;z-index:10;
  background:linear-gradient(180deg,#ffffff, #fbfdff);
  border-bottom:1px solid var(--line);
}
.topbar__inner{display:flex;align-items:center;justify-content:space-between;padding:12px 0}

/* ===== logo ===== */
.logo{
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

/* Force a perfect circle at all sizes */
.logo__img{
  width: 96px;
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: cover;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 2px 6px rgba(15,23,42,0.15);
  display: block;
  flex-shrink: 0;
}

.logo__text{font-size: 19px}

/* Mobile */
@media (max-width: 620px){
  .logo__img{ width: 72px; }
  .logo__text{ font-size: 17px; }
}

.nav{display:flex;gap:16px;align-items:center}
.nav a{color:var(--muted)}
.nav a:hover{color:var(--text)}

.hero{border-bottom:1px solid var(--line);background:linear-gradient(180deg, #ffffff, #f8fafc)}
.hero__inner{padding:32px 0}
.hero h1{margin:0 0 8px;font-size:32px}
.hero__meta{margin-top:14px}

.searchbar{display:flex;gap:10px;margin:18px 0 14px}
.searchbar input{
  flex:1;
  padding:12px 14px;
  border:1px solid var(--line);
  border-radius:12px;
  font-size:14px;
}

.filters{
  display:flex;flex-wrap:wrap;gap:12px;
  padding:14px;
  border:1px solid var(--line);
  border-radius: var(--radius);
  background:#fff;
}
.field{display:flex;flex-direction:column;gap:6px;min-width:160px}
.field-inline{justify-content:flex-end;min-width:auto}
.field label{font-size:12px;color:var(--muted)}
.field input, .field select{
  padding:10px 12px;border:1px solid var(--line);border-radius:12px;font-size:14px;background:#fff;
}
.check{display:flex;gap:10px;align-items:center;padding:10px 12px;border:1px solid var(--line);border-radius:12px;color:var(--text);background:#fff}
.check input{transform:scale(1.1)}

.btn{
  padding:12px 14px;border-radius:12px;border:1px solid var(--line);
  background:#fff;cursor:pointer;font-weight:600;font-size:14px;
}
.btn:hover{box-shadow:var(--shadow)}
.btn-primary{background:var(--primary);border-color:var(--primary);color:#fff}
.btn-primary:hover{background:var(--primary2);border-color:var(--primary2)}
.btn-ghost{background:transparent}

.section{padding:26px 0}
.section__header{display:flex;align-items:flex-end;justify-content:space-between;gap:14px}
.section__header h2{margin:0;font-size:20px}

.grid{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:14px;
  margin-top:14px;
}
@media (max-width: 950px){
  .grid{grid-template-columns: repeat(2, 1fr);}
}
@media (max-width: 620px){
  .grid{grid-template-columns: 1fr;}
  .nav{display:none}
}

/* ===== Featured section (injected by app.js) ===== */
.featuredWrap{ margin-top: 14px; }

.featuredSection{
  border: 1px solid #bbf7d0;
  background: linear-gradient(180deg, #ecfdf5, #ffffff);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(15,23,42,0.06);
}

.featuredHead{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}

.featuredTitle{
  font-size: 16px;
  font-weight: 900;
  letter-spacing: .2px;
}

.featuredSub{
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.featuredPill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  color:#052e16;
  border:1px solid #86efac;
  background: linear-gradient(180deg, #dcfce7, #ecfdf5);
  box-shadow: 0 6px 16px rgba(16,185,129,0.12);
  white-space: nowrap;
}

/* ✅ DESKTOP/TABLET: always horizontal grid */
.featuredRail{
  display:grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap:14px !important;
  align-items:start !important;
}

@media (max-width: 950px){
  .featuredRail{
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* ✅ MOBILE: keep the swipe layout you liked */
@media (max-width: 620px){
  .featuredRail{
    display:flex !important;
    gap:10px !important;
    overflow-x:auto !important;
    padding-bottom:6px !important;
    scroll-snap-type: x mandatory !important;
  }
  .featuredRail .card{
    min-width: calc(50% - 6px) !important;
    scroll-snap-align: start !important;
  }
}

/* ✅ IMPORTANT: do NOT cap widths — let grid handle sizing */
@media (min-width: 621px){
  .featuredRail > *{
    width: auto !important;
    max-width: none !important;
    grid-column: auto !important;
    justify-self: stretch !important;
  }
  .featuredSection .card{
    width: 100% !important;
    max-width: none !important;
  }
}

/* ===== card (now whole card is a link) ===== */
.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius: var(--radius);
  overflow:hidden;
  box-shadow: 0 0 0 rgba(0,0,0,0);
  transition: transform .08s ease, box-shadow .08s ease, border-color .08s ease;
}
.card:hover{transform: translateY(-2px); box-shadow: var(--shadow); border-color: rgba(37,99,235,0.35);}

.cardLink{display:block}
.card__media{background:#e5e7eb}
.card__img{
  width:100%; height:180px; object-fit:cover; background:#e5e7eb; display:block;
}
.card__body{padding:12px}
.price{font-weight:800;font-size:18px}
.title{margin:6px 0 4px;font-weight:800; line-height:1.2}
.meta{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.chip{background:var(--chip);padding:6px 10px;border-radius:999px;font-size:12px;color:var(--text);border:1px solid var(--line)}
.row{display:flex;gap:10px;align-items:center;justify-content:space-between}

.badges{display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end}
.badge{font-size:12px;color:#0b1220;background:#ecfeff;border:1px solid #cffafe;padding:6px 10px;border-radius:999px}

/* ✅ Featured badge: greener + premium */
.badge--featured{
  color:#052e16;
  background: linear-gradient(180deg, #dcfce7, #ecfdf5);
  border:1px solid #86efac;
  font-weight: 900;
  letter-spacing: .2px;
  box-shadow: 0 8px 18px rgba(16,185,129,0.14);
}

/* ✅ scan-friendly key line */
.card__key{
  margin-top:8px;
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
  font-size:13px;
  color: var(--text);
}
.card__type{font-weight:800}
.card__dot{opacity:.35}

/* tighten subline */
.cardSub{margin-top:2px; line-height:1.35}

.empty{border:1px dashed var(--line);border-radius:var(--radius);padding:20px;margin-top:14px;background:#fff}

.cards{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-top:12px}
@media (max-width: 950px){ .cards{grid-template-columns:1fr;} }
.small{padding:14px}
.small h3{margin:0 0 6px}

.footer{border-top:1px solid var(--line);padding:18px 0;background:#fff}
.footer__inner{display:flex;justify-content:space-between;gap:12px}

.detail{display:grid;grid-template-columns: 1.2fr 0.8fr; gap:16px; align-items:start}
@media (max-width: 950px){ .detail{grid-template-columns: 1fr;} }

.panel{border:1px solid var(--line);border-radius:var(--radius);background:#fff;overflow:hidden}
.panel__body{padding:14px}

.actions{display:flex;flex-direction:column;gap:10px}

.skeleton{
  height:420px;border-radius:var(--radius);border:1px solid var(--line);
  background:linear-gradient(90deg,#f1f5f9,#ffffff,#f1f5f9);
  background-size:200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer{0%{background-position:0% 0}100%{background-position:-200% 0}}

.more{display:flex;justify-content:center;margin-top:16px}

/* ✅ infinite scroll sentinel (invisible) */
#scrollSentinel{ height: 1px; width: 100%; }

/* =================== Collage preview =================== */
.photoCollage{
  display:grid;
  grid-template-columns: 1.35fr 1fr;
  gap:10px;
  border-radius:16px;
  overflow:hidden;
}

.photoCollage button{
  border:0;
  padding:0;
  background:transparent;
  cursor:pointer;
  display:block;
  width:100%;
  height:100%;
}

.photoCollage img,
.photoCollage video{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
  background:#e5e7eb;
}

.photoCollage__big{
  min-height:380px;
  border-radius:12px;
  overflow:hidden;
}

.photoCollage__right{
  position:relative;
  display:grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap:10px;
  min-height:380px;
}

.photoCollage__small{
  min-height:0;
  border-radius:12px;
  overflow:hidden;
  position:relative;
}

.photoCollage__overlay{
  position:absolute;
  right:12px;
  bottom:12px;
  z-index:2;
  pointer-events:none;
}

.photoCollage__overlay .showAllBtn{ pointer-events:auto; }

.showAllBtn{
  display:inline-flex;
  align-items:center;
  gap:8px;

  padding:10px 14px;
  border-radius:999px;

  background:rgba(15,23,42,0.75);
  color:#ffffff;

  border:1px solid rgba(255,255,255,0.5);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);

  font-size:14px;
  font-weight:800;
  line-height:1;

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.showAllBtn:hover{
  background:rgba(15,23,42,0.9);
  transform: translateY(-1px);
}

.showAllBtn__icon{
  font-size:14px;
  opacity:1;
}

.showAllBtn__count{
  opacity:0.9;
  font-weight:800;
}

.mediaPlayBadge{
  position:absolute;
  left:10px;
  bottom:10px;
  z-index:2;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.25);
  background:rgba(15,23,42,0.45);
  color:#fff;
  font-size:12px;
  font-weight:700;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events:none;
}

@media (max-width: 900px){
  .photoCollage{ grid-template-columns: 1fr; }
  .photoCollage__big, .photoCollage__right{ min-height:280px; }
}

@media (max-width: 620px){
  .photoCollage{
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .photoCollage__big{
    min-height: 170px;
    border-radius: 14px;
  }

  .photoCollage__right{
    grid-template-columns: 1fr 1fr;
    min-height: 110px;
    gap: 8px;
  }

  .photoCollage__small{
    height: 110px;
    border-radius: 14px;
  }

  .photoCollage__overlay{
    right: 10px;
    bottom: 10px;
  }
}

/* =================== Email form (fix overflow) =================== */
.emailCard{
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  background:#fff;
}

.emailCard__title{
  font-weight:800;
  margin-bottom:10px;
}

.emailForm{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.emailForm__label{
  font-size:12px;
  color:var(--muted);
}

.emailForm__input,
.emailForm__textarea{
  width:100%;
  max-width:100%;
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px 12px;
  font-size:14px;
  outline:none;
}

.emailForm__textarea{
  resize:vertical;
  min-height:90px;
}

.emailForm__btn{ width:100%; }

#leadEmailStatus{ min-height: 16px; }

/* =================== Tabs (Rent / Sale) =================== */
.tabs{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.tabBtn{
  padding:10px 12px;
  border-radius:999px;
  border:1px solid var(--line);
  background:#fff;
  cursor:pointer;
  font-weight:800;
  font-size:13px;
  color:var(--text);
}

.tabBtn:hover{ box-shadow: var(--shadow); }

.tabBtn--active{
  background: rgba(37,99,235,0.10);
  border-color: rgba(37,99,235,0.35);
}

/* =================== Walkability + Map =================== */
.walkRow{ display:flex; flex-direction:column; gap:10px; }

.walkBadge{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--line);
  background:#fff;
  width:fit-content;
}

.walkBadge__num{
  font-size:22px;
  font-weight:900;
  min-width: 44px;
  text-align:center;
  padding:6px 10px;
  border-radius:12px;
  border:1px solid var(--line);
  background: var(--chip);
}

.walkBadge__lbl{ font-weight:800; }

.walkBadge.w90 .walkBadge__num{ background: #dcfce7; border-color:#bbf7d0; }
.walkBadge.w75 .walkBadge__num{ background: #e0f2fe; border-color:#bae6fd; }
.walkBadge.w55 .walkBadge__num{ background: #fef9c3; border-color:#fde68a; }
.walkBadge.w35 .walkBadge__num{ background: #ffedd5; border-color:#fed7aa; }
.walkBadge.w10 .walkBadge__num{ background: #fee2e2; border-color:#fecaca; }

.listingMapWrap{
  margin-top: 10px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.listingMap{
  height: 320px;
  background: #e5e7eb;
}

.leaflet-container{
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

/* =================== Mobile: show more cards (Marketplace style) =================== */
@media (max-width: 620px){
  .grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .card__img{
    height: 120px;
  }

  .card__body{
    padding: 10px;
  }
  .price{
    font-size: 15px;
  }
  .title{
    font-size: 13px;
    margin: 4px 0 2px;
    line-height: 1.15;

    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .cardSub{
    font-size: 11px;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .card__key{
    font-size: 12px;
    gap: 6px;
    margin-top: 6px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .meta{ gap: 6px; margin-top: 6px; }
  .chip{ padding: 4px 8px; font-size: 11px; }
  .badge{ padding: 4px 8px; font-size: 11px; }
}

@media (max-width: 420px){
  .card__img{ height: 105px; }
}

/* =================== Mobile listing page: tighter hero =================== */
@media (max-width: 620px){
  .photoCollage{ gap: 8px; }
  .photoCollage__big{ min-height: 200px; }
  .photoCollage__right{ min-height: 200px; gap: 8px; }
  .photoCollage__small{ height: 96px; }

  .panel__body{ padding: 12px; }

  .panel__body h1{
    font-size: 20px;
    margin: 6px 0 6px;
    line-height: 1.2;
  }

  .meta{ gap: 6px; margin-top: 8px; }
  .chip{ padding: 4px 8px; font-size: 11px; }

  .walkBadge{ padding: 10px 12px; }
  .walkBadge__num{ font-size: 18px; min-width: 38px; }

  .listingMap{ height: 240px; }
}

/* ============================================================
 *   🔥 DESKTOP-ONLY "CANNOT MISS" FIX
 *   Forces Featured cards to be same width as regular grid cards,
 *   EVEN if app.js wraps them or forces spanning.
 * ============================================================ */
@media (min-width: 621px){

  /* same as your normal container width math */
  .featuredSection{
    --feat-gap: 14px;
    --feat-card-w: calc((1100px - (var(--feat-gap) * 2)) / 3);
  }

  /* kill any "span full row" wrapper behavior */
  .featuredRail > *{
    grid-column: auto !important;
    justify-self: start !important;
    width: 100% !important;
    max-width: var(--feat-card-w) !important;
  }

  /* if the .card isn't the direct child, still cap the card itself */
  .featuredSection .card{
    width: 100% !important;
    max-width: var(--feat-card-w) !important;
  }

  /* keep the rail in 3 columns no matter what */
  .featuredRail{
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 14px !important;
    justify-items: start !important;
    align-items: start !important;
  }
}

.featuredSection{
  position:relative;
}

.featuredSection::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius:16px;
  pointer-events:none;
  box-shadow: inset 0 0 0 1px rgba(16,185,129,.35);
}

/* ===== HARD OVERRIDE: Featured rail must be horizontal grid on desktop ===== */
@media (min-width: 621px){
  .featuredSection > div:last-child{
    display:grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap:14px !important;
  }
}

@media (max-width: 950px) and (min-width: 621px){
  .featuredSection > div:last-child{
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
