:root {
  --cielo-50: #f5fbfe;
  --cielo-100: #dcf0fb;
  --cielo-200: #bfe2f6;
  --cielo-400: #6cb9e4;
  --cielo-600: #2f86ba;
  --cielo-800: #1b5479;
  --tinta: #183448;
  --tinta-suave: #50708a;
  --oro: #f2b84b;
  --coral: #e5706a;
  --verde-wa: #1fa855;
  --blanco: #fff;
  --sombra: 0 1px 2px rgb(27 84 121 / .06), 0 6px 18px rgb(27 84 121 / .08);
  --radio: 18px;
  --display: 'Fraunces', Georgia, serif;
  --texto: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--texto);
  color: var(--tinta);
  background: var(--cielo-50) linear-gradient(180deg, var(--cielo-100) 0, var(--cielo-50) 360px) no-repeat;
  line-height: 1.5;
}
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--cielo-400); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Marca ---------- */
.marca {
  margin: 0;
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(2.8rem, 11vw, 4.2rem);
  letter-spacing: -.02em;
  line-height: 1;
  color: var(--cielo-800);
}
.marca.chica { font-size: 1.7rem; }
.destello { color: var(--oro); font-style: normal; font-size: .42em; vertical-align: super; margin-left: .08em; }

/* ---------- Tienda ---------- */
.cabecera { text-align: center; padding: 44px 16px 18px; }
.lema {
  margin: 10px 0 0;
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--tinta-suave);
}

.filtros {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 16px 14px;
  scrollbar-width: none;
  justify-content: safe center;
}
.filtros::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 1.5px solid var(--cielo-200);
  background: var(--blanco);
  border-radius: 999px;
  padding: 6px 16px;
  font-weight: 700;
  font-size: .9rem;
  color: var(--cielo-800);
}
.chip[aria-pressed="true"] { background: var(--cielo-800); border-color: var(--cielo-800); color: var(--blanco); }

.contenido { max-width: 1100px; margin: 0 auto; padding: 0 16px 40px; }
.grilla {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
@media (min-width: 640px) { .grilla { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; } }

.tarjeta {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  text-align: left;
  background: var(--blanco);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
@media (hover: hover) {
  .tarjeta:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgb(27 84 121 / .08), 0 12px 28px rgb(27 84 121 / .14); }
}
.foto { position: relative; display: block; aspect-ratio: 1; background: var(--cielo-100); }
.foto img { width: 100%; height: 100%; object-fit: cover; }
.vendido .foto img { filter: saturate(.35) brightness(1.05); }
.sello {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) rotate(-6deg);
  background: var(--coral);
  color: var(--blanco);
  font-weight: 800;
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 6px;
}
.cuenta {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgb(24 52 72 / .62);
  color: var(--blanco);
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.info { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; flex: 1; }
.titulo {
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.precio { margin-top: auto; padding-top: 4px; font-weight: 800; color: var(--cielo-600); }
.vendido .precio { color: var(--tinta-suave); text-decoration: line-through; }

.vacio { text-align: center; color: var(--tinta-suave); padding: 48px 16px; font-size: 1.05rem; }
.pie { text-align: center; color: var(--tinta-suave); font-size: .85rem; padding: 8px 16px 32px; }

/* ---------- Detalle ---------- */
.detalle {
  width: min(720px, 100%);
  max-width: 100%;
  max-height: 100dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--blanco);
  color: var(--tinta);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.detalle::backdrop { background: rgb(24 52 72 / .55); backdrop-filter: blur(3px); }
.detalle[open] { animation: subir .26s ease-out; }
@keyframes subir { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 760px) {
  .detalle { margin: auto; border-radius: 24px; max-height: calc(100dvh - 48px); }
}
.cerrar {
  position: sticky;
  top: 10px;
  float: right;
  margin: 10px 10px -50px 0;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / .9);
  box-shadow: var(--sombra);
  font-size: 1.6rem;
  line-height: 1;
}
.carrusel-marco { position: relative; }
.carrusel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  aspect-ratio: 1;
  max-height: 72dvh;
  background: var(--cielo-100);
}
.carrusel::-webkit-scrollbar { display: none; }
.carrusel img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: contain; scroll-snap-align: center; }
.flecha {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / .85);
  box-shadow: var(--sombra);
  font-size: 1.6rem;
  line-height: 1;
  display: none;
}
.flecha.ant { left: 10px; }
.flecha.sig { right: 10px; }
@media (hover: hover) { .flecha { display: block; } }
.puntos { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.puntos span { width: 7px; height: 7px; border-radius: 50%; background: rgb(255 255 255 / .7); box-shadow: 0 0 0 1px rgb(24 52 72 / .15); transition: transform .2s; }
.puntos span.activo { background: var(--cielo-600); transform: scale(1.25); }

.detalle-info { padding: 18px 20px 28px; }
.detalle-cat { margin: 0; font-size: .75rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--cielo-600); }
.detalle-titulo { margin: 4px 0 2px; font-family: var(--display); font-weight: 500; font-size: 1.7rem; line-height: 1.2; }
.detalle-precio { margin: 0 0 12px; font-size: 1.35rem; font-weight: 800; color: var(--cielo-600); }
.detalle-precio.es-vendido { color: var(--coral); }
.texto p { margin: 0 0 .7em; }
.texto ul { margin: 0 0 .7em; padding-left: 1.2em; }
.texto li::marker { color: var(--cielo-400); }
.texto strong { font-weight: 800; }
.boton-wa {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  background: var(--verde-wa);
  color: var(--blanco);
  font-weight: 800;
  text-decoration: none;
}

/* ---------- Panel ---------- */
.panel { padding-bottom: 40px; }
.panel-cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 680px;
  margin: 0 auto;
  padding: 18px 16px 10px;
}
.ver-tienda { font-weight: 700; color: var(--cielo-600); text-decoration: none; }
.cargando { text-align: center; color: var(--tinta-suave); }
.tarjeta-panel {
  max-width: 680px;
  margin: 0 auto 16px;
  padding: 20px 18px;
  background: var(--blanco);
  border-radius: 22px;
  box-shadow: var(--sombra);
}
@media (min-width: 712px) { .tarjeta-panel { padding: 24px 26px; } }
#app { padding: 0 16px; }
#vincular { margin-left: 16px; margin-right: 16px; }
@media (min-width: 712px) { #vincular { margin-left: auto; margin-right: auto; } }
.tarjeta-panel h1, .tarjeta-panel h2 { margin: 0 0 14px; font-family: var(--display); font-weight: 500; font-size: 1.5rem; color: var(--cielo-800); }
.contador { font-family: var(--texto); font-size: 1rem; color: var(--tinta-suave); }

.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; min-width: 0; }
.etiqueta { font-weight: 800; font-size: .9rem; }
.etiqueta-mini { display: block; font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--tinta-suave); margin-bottom: 6px; }
.ayuda { margin: 0; font-size: .82rem; color: var(--tinta-suave); }
.ayuda code { background: var(--cielo-100); border-radius: 5px; padding: 0 4px; font-size: .8rem; white-space: nowrap; }
.fila { display: flex; gap: 10px; flex-wrap: wrap; }
.fila > * { flex: 1 1 140px; }
.campos-dobles > .campo { flex: 1 1 200px; }

input[type="password"], input:not([type]), textarea {
  width: 100%;
  border: 1.5px solid var(--cielo-200);
  border-radius: 12px;
  padding: 11px 12px;
  background: var(--cielo-50);
  font-size: 1rem; /* 16px: evita el zoom de iOS */
}
input:focus, textarea:focus { outline: none; border-color: var(--cielo-400); background: var(--blanco); }
textarea { resize: vertical; min-height: 120px; }
.con-prefijo { position: relative; }
.con-prefijo span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 800; color: var(--tinta-suave); }
.con-prefijo input { padding-left: 26px; }

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 12px;
  padding: 11px 18px;
  background: var(--cielo-600);
  color: var(--blanco);
  font-weight: 800;
  text-align: center;
  user-select: none;
}
.boton.grande { padding: 14px 18px; font-size: 1.02rem; }
.boton.secundario { background: var(--cielo-100); color: var(--cielo-800); }
.boton:disabled { opacity: .6; cursor: wait; }

.previas {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}
.previas:empty { display: none; }
.previa {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--cielo-100);
  display: grid;
  place-items: center;
}
.previa img { width: 100%; height: 100%; object-fit: cover; }
.previa.portada { box-shadow: 0 0 0 3px var(--oro); }
.marca-portada {
  position: absolute;
  left: 4px;
  bottom: 4px;
  background: var(--oro);
  color: var(--tinta);
  font-size: .66rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 6px;
}
.mini {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / .9);
  font-size: .9rem;
  line-height: 1;
  box-shadow: 0 1px 3px rgb(0 0 0 / .2);
}
.mini.quitar { top: 4px; right: 4px; }
.mini.estrella { bottom: 4px; left: 4px; color: var(--oro); }
.foto-error { font-size: .72rem; text-align: center; padding: 6px; color: var(--coral); font-weight: 700; }
.girando { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--cielo-200); border-top-color: var(--cielo-600); animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

.herramientas { display: flex; gap: 6px; flex-wrap: wrap; margin-top: -2px; }
.herramientas button {
  min-width: 42px;
  height: 38px;
  padding: 0 10px;
  border: 1.5px solid var(--cielo-200);
  border-radius: 10px;
  background: var(--blanco);
  color: var(--cielo-800);
  font-size: .95rem;
}
.vista-previa { margin-top: 4px; padding: 12px 14px; border-radius: 12px; background: var(--cielo-50); border: 1.5px dashed var(--cielo-200); }
.vista-previa .texto > :last-child { margin-bottom: 0; }
.vista-titulo { font-family: var(--display); font-size: 1.2rem; }

.check { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 16px; }
.check input { width: 20px; height: 20px; accent-color: var(--cielo-600); }

.progreso { height: 8px; border-radius: 99px; background: var(--cielo-100); overflow: hidden; margin-bottom: 12px; }
.progreso span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cielo-400), var(--cielo-600)); transition: width .3s; }
.error { color: var(--coral); font-weight: 700; margin: 0 0 10px; }
.error:empty { display: none; }
.acciones { margin-top: 4px; }

.mis-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.item { display: flex; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--cielo-100); }
.item:last-child { border-bottom: 0; padding-bottom: 0; }
.item > img { width: 76px; height: 76px; flex: none; border-radius: 12px; object-fit: cover; background: var(--cielo-100); }
.item.es-oculto > img { opacity: .45; }
.item-info { min-width: 0; flex: 1; }
.item-titulo { margin: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-datos { margin: 2px 0 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .88rem; color: var(--tinta-suave); font-weight: 700; }
.tag { background: var(--cielo-100); color: var(--cielo-800); border-radius: 6px; padding: 0 7px; font-size: .75rem; }
.tag.coral { background: #fde3e1; color: #b8433d; }
.tag.gris { background: #eceff2; color: #5d6b77; }
.item-acciones { display: flex; flex-wrap: wrap; gap: 6px; }
.item-acciones button {
  border: 1.5px solid var(--cielo-200);
  background: var(--blanco);
  border-radius: 9px;
  padding: 4px 9px;
  font-size: .8rem;
  font-weight: 700;
  color: var(--cielo-800);
}
.item-acciones .peligro { color: #b8433d; border-color: #f6c9c5; }
.item-acciones .peligro[data-confirmar] { background: var(--coral); color: var(--blanco); border-color: var(--coral); }

.desvincular { display: block; margin: 8px auto 0; border: 0; background: none; color: var(--tinta-suave); text-decoration: underline; font-size: .85rem; }
.desvincular[data-confirmar] { color: var(--coral); font-weight: 800; }

.aviso {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--tinta);
  color: var(--blanco);
  padding: 11px 18px;
  border-radius: 12px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgb(0 0 0 / .2);
  z-index: 10;
}
