/* ================= Patio ================= */

:root {
  --cream: #FAF4E8;
  --cream-2: #F3EAD8;
  --ink: #1C1814;
  --ink-soft: #5C544A;
  --terra: #E2593A;
  --terra-dark: #C6462A;
  --sage: #7C9A6D;
  --sun: #F2B33D;
  --card: #FFFDF7;
  --border: 1.5px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 2.5px 2.5px 0 var(--ink);
  --radius: 14px;
  --font-display: "Bricolage Grotesque", sans-serif;
  --font-body: "Instrument Sans", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }

/* el sitio siempre es claro: sin esto, iOS en modo oscuro re-pinta inputs y botones */
:root { color-scheme: light only; }

/* Safari iOS mete su propio estilo a los controles: se neutraliza para que
   el celular se vea idéntico a la computadora */
button,
select,
textarea,
input:not([type="checkbox"]):not([type="radio"]):not([type="date"]):not([type="file"]) {
  -webkit-appearance: none;
  appearance: none;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration { -webkit-appearance: none; display: none; }

/* iOS pinta botones y selects de azul sistema si no se les fija el color */
button, select { color: var(--ink); }

html, body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image: radial-gradient(var(--cream-2) 1.2px, transparent 1.2px);
  background-size: 26px 26px;
}

/* skyline punteado de la ciudad activa, al lado del título */
#skyline-mark {
  position: absolute;
  right: 0;
  bottom: -70px; /* la base alineada con la parte de abajo del search bar */
  width: min(600px, 52%);
  aspect-ratio: 1440 / 560; /* estirado en Y: más alto, mismo ancho */
  pointer-events: none;
  opacity: 0.55;
  background-image: url('/img/skyline-boston.svg');
  background-repeat: no-repeat;
  background-position: bottom right;
  background-size: 100% 100%;
}
body[data-city="nyc"] #skyline-mark { background-image: url('/img/skyline-nyc.svg'); }
body[data-city="miami"] #skyline-mark { background-image: url('/img/skyline-miami.svg'); }

/* avioneta con pancarta: cruza volando el ancho del skyline, en loop */
#city-chant {
  position: absolute;
  right: 0;
  top: 50px; /* a la altura de "Lo que se vende" */
  width: min(600px, 52%); /* mismos márgenes que el skyline */
  height: 64px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.75;
}
.chant-fly {
  position: absolute;
  top: 50%;
  left: 0;
  display: flex;
  align-items: center;
  white-space: nowrap;
  animation: chant-fly 23s linear infinite;
}
@keyframes chant-fly {
  from { left: 0; transform: translate(-100%, -50%); }
  to { left: 100%; transform: translate(0, -50%); }
}
@media (prefers-reduced-motion: reduce) {
  .chant-fly { animation: none; left: 50%; transform: translate(-50%, -50%); }
  #listings-grid .card, #fav-grid .card,
  .modal:not(.hidden), .modal:not(.hidden) .modal-card { animation: none; }
}
.chant-banner {
  border: 2.5px dotted var(--ink);
  border-radius: 8px;
  padding: 8px 18px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.35rem, 2.3vw, 2rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  /* letras rellenas de puntitos, como el skyline (trama fina = más legible) */
  background-image: radial-gradient(var(--ink) 1px, transparent 1px);
  background-size: 3.5px 3.5px;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.chant-rope {
  width: 30px;
  border-top: 2.5px dotted var(--ink);
  opacity: 0.8;
}
.chant-plane { width: 84px; height: auto; display: block; }

@media (max-width: 780px) {
  #skyline-mark, #city-chant { display: none; }
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 1rem; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }

/* ---------- top bar ---------- */

.topbar {
  position: fixed;
  top: 14px;
  left: 16px;
  right: 16px;
  z-index: 500;
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 12px 8px 20px;
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.78);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border: 1px solid rgba(28, 24, 20, 0.12);
  box-shadow: 0 8px 30px rgba(28, 24, 20, 0.08);
  transition: box-shadow 0.3s, background 0.3s;
}
.topbar.is-scrolled {
  background: rgba(255, 253, 247, 0.94);
  box-shadow: 0 14px 40px rgba(28, 24, 20, 0.14);
}

.logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
  transition: transform 0.35s ease;
}
.logo:hover { transform: rotate(-5deg) scale(1.07); }
.logo-dot { color: var(--terra); }

.topnav { display: flex; gap: 4px; }
.navlink {
  border: none;
  background: none;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 9px 15px;
  border-radius: 999px;
  color: var(--ink-soft);
  transition: background 0.2s, color 0.2s;
}
.navlink:hover { background: rgba(28, 24, 20, 0.07); color: var(--ink); }
.navlink.active {
  background: var(--ink);
  color: var(--cream);
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.city-select {
  border: var(--border);
  border-radius: 999px;
  background: var(--card);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.2s, color 0.2s;
}
.city-select:hover,
#auth-btn:hover {
  background: var(--terra);
  color: #fff;
}

/* logueado: el botón es la inicial, redonda */
#auth-btn.avatar-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  border: var(--border);
  border-radius: 50%;
  background: var(--sun);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}
#auth-btn.avatar-btn:hover { background: var(--terra); color: #fff; }

.profile-lang { display: flex; justify-content: flex-end; margin-top: 6px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-block;
  border: var(--border);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 0.98rem;
  font-weight: 600;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn-primary { background: var(--terra); color: #fff; }
.btn-primary:hover { background: var(--terra-dark); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-small { padding: 7px 14px; font-size: 0.88rem; }
.btn-big { width: 100%; padding: 15px; font-size: 1.05rem; box-shadow: var(--shadow); }
.btn-danger { background: #fff; color: var(--terra-dark); }

/* ---------- views ---------- */

main { max-width: 1080px; margin: 0 auto; padding: 96px 18px 110px; /* aire para el nav flotante */ }
.view { display: none; }
.view.active { display: block; }

.hero { padding: 46px 4px 10px; position: relative; }
.hero h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  margin: 0 0 12px;
}
.accent { color: var(--terra); }
.hero-sub { font-size: 1.1rem; color: var(--ink-soft); max-width: 460px; margin: 0; }

.view-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: -0.03em;
  margin: 34px 0 6px;
}

.section-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  margin: 30px 0 12px;
}

/* ---------- toolbar / chips ---------- */

.toolbar { padding: 22px 0 8px; }

.search-wrap input {
  flex: 1;
  min-width: 0;
  max-width: 340px;
  border: var(--border);
  border-radius: 999px;
  background: var(--card);
  padding: 13px 20px;
  box-shadow: var(--shadow-sm);
  outline: none;
}
.search-wrap input:focus { box-shadow: var(--shadow); }

.search-wrap { display: flex; gap: 10px; align-items: center; }
.sort-select {
  -webkit-appearance: none;
  appearance: none;
  border: var(--border);
  border-radius: 999px;
  background: var(--card);
  padding: 12px 16px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  white-space: nowrap;
}
.sort-select:hover { background: var(--terra); color: #fff; }

.chips {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  padding: 16px 0 4px;
}
.chip {
  border: var(--border);
  border-radius: 999px;
  background: var(--card);
  padding: 7px 15px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.chip:nth-child(even) { transform: rotate(-1deg); }
.chip:nth-child(odd) { transform: rotate(0.8deg); }
.chip.active {
  background: var(--ink);
  color: var(--cream);
  transform: rotate(0deg) scale(1.04);
}

/* ---------- grid & cards ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
  padding: 18px 0;
}

.card {
  position: relative;
  background: var(--card);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.fav-btn {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 2;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  font-size: 1.05rem;
  line-height: 1;
  color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
}
.fav-btn.on { background: var(--terra); color: #fff; }
.card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }

.card-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  border-bottom: var(--border);
  background: var(--cream-2);
}

.card-body { padding: 12px 14px 14px; }
.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  margin: 0 0 4px;
  line-height: 1.25;
}
.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.card-price { font-weight: 700; font-size: 1.05rem; }
.card-zone { font-size: 0.82rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-distance { font-size: 0.78rem; color: var(--sage); font-weight: 600; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  margin-bottom: 7px;
}
.badge-sublease { background: var(--sun); }
.badge-new { background: var(--sage); color: #fff; }
.badge-sold { background: var(--ink); color: var(--cream); }
.badge-pending { background: var(--cream-2); color: var(--ink-soft); border-style: dashed; }

.card.sold .card-img { filter: grayscale(1) opacity(0.65); }

/* tarjetas que van apareciendo en cascada */
#listings-grid .card, #fav-grid .card { animation: card-in 0.4s ease backwards; }
#listings-grid .card:nth-child(1) { animation-delay: 0.03s; }
#listings-grid .card:nth-child(2) { animation-delay: 0.07s; }
#listings-grid .card:nth-child(3) { animation-delay: 0.11s; }
#listings-grid .card:nth-child(4) { animation-delay: 0.15s; }
#listings-grid .card:nth-child(5) { animation-delay: 0.19s; }
#listings-grid .card:nth-child(6) { animation-delay: 0.23s; }
#listings-grid .card:nth-child(7) { animation-delay: 0.27s; }
#listings-grid .card:nth-child(8) { animation-delay: 0.31s; }
@keyframes card-in { from { opacity: 0; transform: translateY(14px); } }

/* esqueletos mientras carga el feed */
.card-skeleton { pointer-events: none; }
.sk-img {
  aspect-ratio: 4 / 3;
  background: linear-gradient(100deg, var(--cream-2) 40%, rgba(255,255,255,0.7) 50%, var(--cream-2) 60%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.2s linear infinite;
}
.sk-line {
  height: 13px;
  border-radius: 6px;
  margin: 8px 0;
  background: linear-gradient(100deg, var(--cream-2) 40%, rgba(255,255,255,0.7) 50%, var(--cream-2) 60%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.2s linear infinite;
}
@keyframes sk-shimmer { to { background-position: -200% 0; } }

.my-item-stats { color: var(--ink-soft); font-size: 0.78rem; }

.btn-wa-invite {
  margin-top: 10px;
  padding: 11px;
  font-size: 0.95rem;
}

/* ---------- empty states ---------- */

.empty { text-align: center; padding: 70px 20px; }
.empty-big {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  margin: 0 0 6px;
}
.empty .btn { margin-top: 18px; }

/* ---------- map view ---------- */

.toolbar-map { padding: 18px 0 4px; }
.toolbar-map .search-wrap input { padding: 11px 18px; max-width: 480px; }
.chips-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chips-scroll::-webkit-scrollbar { display: none; }
.chips-scroll .chip { white-space: nowrap; flex-shrink: 0; }

#map-count { font-weight: 600; color: var(--ink); }

#big-map {
  height: calc(100vh - 350px);
  height: calc(100dvh - 350px); /* Safari iOS: la barra de URL cambia el vh */
  min-height: 360px;
  margin-top: 10px;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 1;
}

.map-legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 4px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--ink); display: inline-block; }
.dot-muebles { background: var(--terra); }
.dot-boletos { background: var(--sun); }
.dot-sublease { background: var(--sage); }
.dot-otros { background: var(--card); }

.map-popup { font-family: var(--font-body); }
.map-popup img { width: 100%; border-radius: 8px; margin-bottom: 6px; }
.map-popup b { font-family: var(--font-display); }

/* ---------- post form ---------- */

.post-wrap { max-width: 620px; margin: 0 auto; }

.quota-note {
  background: var(--card);
  border: var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  padding: 10px 14px;
  font-size: 0.92rem;
  margin: 10px 0 24px;
}

.field { display: block; margin-bottom: 20px; }
.field > span {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 7px;
}
.field em { font-style: normal; font-weight: 400; color: var(--ink-soft); }

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field input[type="search"],
.field textarea {
  width: 100%;
  border: var(--border);
  border-radius: 10px;
  background: var(--card);
  padding: 12px 14px;
  outline: none;
  resize: vertical;
  -webkit-appearance: none;
  appearance: none;
}
.field input:focus, .field textarea:focus { box-shadow: var(--shadow-sm); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chips-form { padding-top: 2px; }

.photo-drop {
  border: 1.5px dashed var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  padding: 26px;
  text-align: center;
  color: var(--ink-soft);
  cursor: pointer;
}
.photo-drop:hover { background: var(--cream-2); }
.photo-drop-cta { font-weight: 600; }

.photo-previews { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.photo-previews .thumb {
  position: relative;
  width: 82px; height: 82px;
  border: var(--border); border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.photo-previews img { width: 100%; height: 100%; object-fit: cover; }
.thumb-x {
  position: absolute; top: 2px; right: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--cream);
  font-size: 0.65rem; line-height: 1;
}

.loc-search { display: flex; gap: 8px; margin-bottom: 10px; }
.loc-search input {
  flex: 1; min-width: 0;
  border: var(--border); border-radius: 10px;
  background: var(--card);
  padding: 10px 14px;
  outline: none;
}

.price-old {
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.85em;
  margin-right: 5px;
}

#pick-map {
  height: 260px;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
  z-index: 1;
}

.fee-notice {
  background: var(--sun);
  border: var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  padding: 12px 16px;
  font-size: 0.94rem;
  margin-bottom: 18px;
}
.fee-notice.toast { animation: toast-in 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 14px); } }

.form-error { color: var(--terra-dark); font-weight: 600; min-height: 1.2em; margin: 12px 0 0; }

/* ---------- profile ---------- */

.profile-head { display: flex; align-items: center; gap: 16px; margin: 40px 0 20px; }
.avatar {
  width: 58px; height: 58px;
  border-radius: 50%;
  border: var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--sun);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 800; font-size: 1.5rem;
}

.profile-stats { display: flex; gap: 14px; flex-wrap: wrap; }
.stat {
  background: var(--card);
  border: var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 12px 18px;
  min-width: 100px;
}
.stat b { font-family: var(--font-display); font-size: 1.5rem; display: block; }
.stat span { font-size: 0.82rem; color: var(--ink-soft); }

.ref-card {
  background: var(--card);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  margin: 22px 0 4px;
}
.ref-card h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 6px; }
.ref-card p { margin: 0 0 12px; font-size: 0.92rem; }
.ref-card #ref-stats { margin: 10px 0 0; font-size: 0.85rem; }
.ref-link-row { display: flex; gap: 8px; }
.ref-link-row input {
  flex: 1; min-width: 0;
  border: var(--border); border-radius: 10px;
  background: var(--cream-2);
  padding: 9px 12px;
  font-size: 0.85rem;
}

.my-listings { display: flex; flex-direction: column; gap: 12px; margin-bottom: 28px; }
#myposts-list { max-width: 640px; }

.my-item {
  display: flex; gap: 14px; align-items: center;
  background: var(--card);
  border: var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 10px;
}
.my-item img {
  width: 64px; height: 64px; object-fit: cover;
  border-radius: 9px; border: 1.5px solid var(--ink);
}
.my-item-info { flex: 1; min-width: 0; }
.my-item-info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.my-item-info small { color: var(--ink-soft); }
.my-item-actions { display: flex; flex-direction: column; gap: 6px; }

/* ---------- tab bar (mobile) ---------- */

.tabbar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 600;
  background: var(--cream);
  border-top: var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  justify-content: space-around;
}
.tab {
  border: none; background: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 0.7rem; font-weight: 600;
  color: var(--ink-soft);
  padding: 4px 10px;
  border-radius: 12px;
}
.tab.active { color: var(--ink); }
.tab-icon { font-size: 1.25rem; line-height: 1; height: 20px; display: flex; align-items: center; justify-content: center; }
.tab-icon svg { display: block; }

/* indicador deslizante: la rayita naranja viaja hasta la pestaña activa */
.tab-indicator {
  position: absolute;
  top: 0; left: 0;
  height: 4px;
  border-radius: 0 0 999px 999px;
  background: var(--terra);
  opacity: 0;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
              width 0.32s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.2s ease;
  will-change: transform;
  pointer-events: none;
}
.tab.active .tab-icon { animation: tab-pop 0.35s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes tab-pop { 40% { transform: scale(1.28); } }
@media (prefers-reduced-motion: reduce) {
  .tab-indicator { transition: opacity 0.2s ease; }
  .tab.active .tab-icon { animation: none; }
}
.tab-post .tab-icon {
  background: var(--terra); color: #fff;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1.5px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}

/* ---------- modals ---------- */

.modal {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(28, 24, 20, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.modal-card {
  position: relative;
  background: var(--cream);
  border: var(--border);
  border-radius: 18px;
  box-shadow: 8px 8px 0 var(--ink);
  width: 100%; max-width: 420px;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 26px;
}
.modal-card-wide { max-width: 560px; padding: 0; }

/* entrada de modales: fade del fondo + tarjeta que sube */
.modal:not(.hidden) { animation: modal-fade 0.2s ease; }
.modal:not(.hidden) .modal-card { animation: modal-up 0.26s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes modal-fade { from { opacity: 0; } }
@keyframes modal-up { from { opacity: 0; transform: translateY(22px) scale(0.98); } }
.modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--cream);
  font-size: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.phone-row { display: flex; gap: 8px; }
.phone-row select {
  border: var(--border);
  border-radius: 10px;
  background: var(--card);
  padding: 12px 8px;
  font-size: 1rem;
  outline: none;
  flex-shrink: 0;
}
.phone-row input { flex: 1; min-width: 0; }
.phone-row #custom-code { flex: 0 0 76px; text-align: center; }
.phone-hint {
  display: block;
  font-style: normal;
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin-top: 6px;
}

.auth-switch { text-align: center; font-size: 0.9rem; margin: 18px 0 0; }
.auth-switch a { color: var(--ink-soft); font-weight: 600; }

.enter-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  margin: 4px 0 20px;
}
.enter-disclaimer {
  background: var(--cream-2);
  border: 1.5px dashed var(--ink);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin: -6px 0 20px;
}

/* ---------- detail modal ---------- */

.detail-photos { position: relative; }
.detail-photos img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  border-bottom: var(--border);
  border-radius: 17px 17px 0 0;
}
.photo-nav {
  position: absolute; bottom: 10px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 6px;
}
.photo-nav i {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(255,255,255,0.6); border: 1px solid var(--ink);
}
.photo-nav i.on { background: var(--terra); }

.detail-body { padding: 20px 24px 26px; }
.detail-title {
  font-family: var(--font-display);
  font-weight: 800; font-size: 1.5rem;
  letter-spacing: -0.02em;
  margin: 4px 0 2px;
}
.detail-price { font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; color: var(--terra-dark); }
.detail-zone { color: var(--ink-soft); font-size: 0.92rem; margin: 4px 0 14px; }
.detail-desc { white-space: pre-wrap; line-height: 1.55; margin: 0 0 18px; }
.detail-mini-map { height: 170px; border: var(--border); border-radius: 12px; margin-bottom: 18px; z-index: 1; }
.detail-seller { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: 0.94rem; }

.btn-wa {
  background: #25D366; color: #fff;
  width: 100%; text-align: center;
  text-decoration: none;
  padding: 14px;
  font-size: 1.02rem;
  border-radius: 999px;
  border: var(--border);
  box-shadow: var(--shadow);
  font-weight: 700;
  display: block;
}

.btn-share {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border-radius: 999px;
  font-weight: 700;
}

.detail-owner {
  border: var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(242, 179, 61, 0.12);
}

.detail-more { margin-top: 22px; }
.detail-more h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0 0 10px;
}
.detail-more-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
}
.mini-card {
  flex: 0 0 128px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.mini-card img {
  width: 128px;
  height: 96px;
  object-fit: cover;
  border: var(--border);
  border-radius: 10px;
}
.mini-title {
  font-size: 0.82rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 128px;
}
.mini-price {
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--terra-dark);
}
.detail-owner .muted { margin: 0 0 10px; text-align: center; }
.detail-owner-btns { display: flex; gap: 10px; }
.detail-owner-btns .btn { flex: 1; }

/* ---------- responsive ---------- */

@keyframes sheet-up { from { opacity: 0; transform: translateY(45%); } }

@media (max-width: 720px) {
  .topnav { display: none; }
  .tabbar { display: flex; }
  .topbar { left: 10px; right: 10px; top: 10px; gap: 10px; }
  main { padding-top: 84px; }
  .hero { padding-top: 20px; }
  .field-row { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  #big-map { height: calc(100vh - 390px); height: calc(100dvh - 390px); min-height: 300px; }

  /* selects a 16px: Safari iOS hace zoom automático si son más chicos */
  .city-select, .sort-select { font-size: 1rem; }
  .sort-select { padding: 11px 12px; }

  /* categorías en carrusel horizontal (una sola línea, como el mapa) */
  #category-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #category-chips::-webkit-scrollbar { display: none; }
  #category-chips .chip { white-space: nowrap; flex-shrink: 0; }

  /* modales como hoja inferior a todo el ancho */
  .modal { padding: 0; align-items: flex-end; }
  .modal-card {
    max-width: none;
    border-radius: 22px 22px 0 0;
    border-left: none; border-right: none; border-bottom: none;
    box-shadow: none;
    max-height: 92vh;
    max-height: 92dvh;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  }
  .modal-card-wide { padding: 0 0 env(safe-area-inset-bottom); }
  .modal:not(.hidden) .modal-card { animation: sheet-up 0.3s cubic-bezier(0.22, 1, 0.36, 1); }

  /* dedos, no cursores */
  .btn-small { padding: 10px 15px; }
  .fav-btn { width: 30px; height: 30px; font-size: 0.88rem; }
  .photo-nav i { width: 12px; height: 12px; }
  .detail-body { padding: 18px 18px 24px; }
  .detail-owner-btns .btn { padding: 12px; }
  .detail-photos img { border-radius: 21px 21px 0 0; }
}

/* feedback táctil al presionar */
.card:active { transform: scale(0.98); }
.btn:active, .chip:active, .tab:active { transform: scale(0.97); }
