:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-2: #f4f2ee;
  --text: #1c1c1c;
  --muted: #79746a;
  --border: #e7e3dd;
  --accent: #2f6b4f;
  --accent-dark: #234f3a;
  --accent-soft: #e4efe7;
  --accent-contrast: #ffffff;
  --new: #b8862f;
  --new-soft: #f7ead1;
  --danger: #b3432b;
  --danger-soft: #f9e4dd;
  --warn: #b8862f;
  --warn-soft: #f7ead1;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 2px 10px rgba(28, 22, 14, 0.06);
  --shadow-hover: 0 10px 24px rgba(28, 22, 14, 0.12);
  --max-width: 560px;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

a {
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
}

.app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

/* Header ------------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px;
  background: rgba(250, 249, 247, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 22px;
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.topbar .subtitle {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.icon-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.92);
  background: var(--surface-2);
}

/* Value props strip --------------------------------------------- */
.value-props {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 12px 16px 4px;
}

.value-props-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  font-size: 10.5px;
  line-height: 1.25;
  color: var(--muted);
  font-weight: 600;
}

.vp-icon {
  color: var(--accent);
  flex: none;
}

/* Filters ------------------------------------------------------ */
.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 16px 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filter-chip.active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.size-filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 16px 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.size-filters::-webkit-scrollbar {
  display: none;
}

.size-chip {
  flex: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.size-chip.active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

/* Grid ---------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 8px 16px 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  padding: 0;
  box-shadow: var(--shadow);
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-hover);
}

.card .photo-wrap {
  aspect-ratio: 3 / 4;
  background: var(--surface-2);
  overflow: hidden;
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card .info {
  padding: 10px 11px 12px;
}

.card .price {
  font-weight: 800;
  font-size: 15.5px;
  letter-spacing: -0.01em;
}

.card .title {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card .card-tags {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.card .mini-tag {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 2px 7px;
}

.badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  color: #fff;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.badge.new {
  background: var(--new-soft);
  color: var(--new);
}

.badge.reservada {
  background: var(--warn);
}

.badge.vendida {
  background: var(--danger);
}

.empty-state {
  padding: 70px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-state-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  margin-bottom: 12px;
}

.empty-state-title {
  font-weight: 700;
  color: var(--text);
  font-size: 15px;
}

.empty-state-sub {
  font-size: 13px;
  margin-top: 4px;
}

/* Skeleton loading ------------------------------------------------ */
.skeleton-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}

.skeleton-card .photo-wrap {
  aspect-ratio: 3 / 4;
}

.skeleton-shimmer {
  background: linear-gradient(100deg, var(--surface-2) 30%, #ebe8e2 45%, var(--surface-2) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}

.skeleton-line {
  height: 10px;
  border-radius: 6px;
  margin: 10px 11px;
}

.skeleton-line.short {
  width: 55%;
}

@keyframes shimmer {
  0% {
    background-position: 150% 0;
  }
  100% {
    background-position: -50% 0;
  }
}

/* Detail modal --------------------------------------------------- */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 10, 0.4);
  z-index: 50;
  display: flex;
  align-items: flex-end;
}

.detail-sheet {
  background: var(--bg);
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 24px 24px 0 0;
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
  position: relative;
}

.detail-close,
.detail-share {
  position: absolute;
  top: 10px;
  z-index: 5;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(20, 16, 10, 0.5);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-close {
  right: 10px;
}

.detail-share {
  left: 10px;
}

.gallery {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.gallery img {
  flex: none;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  scroll-snap-align: start;
}

.gallery-dots {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
}

.gallery-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  transition: background 0.15s ease, transform 0.15s ease;
}

.gallery-dots .dot.active {
  background: #fff;
  transform: scale(1.25);
}

.detail-body {
  padding: 18px 16px 6px;
}

.detail-body .price {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.detail-body .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
}

.detail-body .description-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-top: 14px;
}

.detail-body .description {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  margin-top: 6px;
}

.reserve-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
  /* Tiene que ir por encima de .detail-overlay (z-index: 50), si no queda
     tapado y los botones (Reservar / Publicar / Descartar) no se pueden tocar. */
  z-index: 60;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  text-align: center;
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-small {
  padding: 8px 12px;
  font-size: 13px;
  width: auto;
  border-radius: 10px;
}

.wa-icon {
  flex: none;
}

/* Admin ----------------------------------------------------------- */
.admin-section {
  padding: 16px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 5px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

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

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.photo-preview {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: var(--surface);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.status-banner {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  margin-bottom: 14px;
}

.status-banner.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: -2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.item-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.item-row img {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
}

.item-row .info {
  flex: 1;
  min-width: 0;
}

.item-row .info .name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-row .info .sub {
  font-size: 12px;
  color: var(--muted);
}

.item-row .actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.login-box {
  max-width: 340px;
  margin: 15vh auto 0;
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  font-size: 13.5px;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Toasts / avisos flotantes ---------------------------------------
   Usado para "Link copiado", y como red de seguridad si el navegador
   bloquea el redirect automático a WhatsApp al reservar (ver
   reserveItem en js/catalog.js). */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--text);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
  z-index: 70;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  animation: toast-in 0.2s ease;
}

.toast svg {
  flex: none;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast a {
  color: #9be0b8;
  font-weight: 700;
  text-decoration: underline;
}
