:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #16181d;
  --muted: #5d6470;
  --line: #e2e5ea;
  --brand: #0a5bbf;
  --brand-ink: #ffffff;
  --ok: #1f7a3d;
  --ok-bg: #e6f4ea;
  --wait: #8a5a00;
  --wait-bg: #fff3d6;
  --wa: #1fa855;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: #0f1115; color: #fff;
}
.marca { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; }
.marca img { border-radius: 8px; }
.marca small { display: block; font-weight: 400; opacity: .7; font-size: 12px; }
/* Estilo AliExpress: carrito blanco, cantidad naranja encima, "Carrito" en negrita */
.btn-carrito {
  --naranja: #ff6a00;
  position: relative; display: inline-flex; align-items: flex-end; gap: 6px;
  background: none; color: #fff; border: 0; border-radius: 10px;
  padding: 6px 8px; font-weight: 700; font-size: 16px;
  transition: color .15s ease, background .15s ease, transform .15s ease;
}
.btn-carrito:hover { background: rgba(255,255,255,.08); color: var(--naranja); }
.btn-carrito:hover .ico-carrito { animation: meneo .4s ease; }
.btn-carrito:active { transform: scale(.94); }
.btn-carrito:focus-visible { outline: 2px solid var(--naranja); outline-offset: 2px; }
.ico-carrito { width: 30px; height: 30px; flex: none; }
.txt-carrito { line-height: 1; padding-bottom: 3px; }
.badge {
  position: absolute; top: 0; left: 24px;
  color: var(--naranja); font-size: 14px; font-weight: 800; line-height: 1;
  text-shadow: 0 0 3px #0f1115, 0 0 3px #0f1115;
}
@keyframes meneo { 0%, 100% { transform: none; } 25% { transform: rotate(-10deg); } 75% { transform: rotate(8deg); } }
.badge[data-vacio] { display: none; }
.btn-carrito.rebote { animation: rebote .45s ease; }
.badge.pop { animation: pop .4s ease; }
@keyframes rebote { 0%, 100% { transform: none; } 30% { transform: scale(1.12) rotate(-4deg); } 60% { transform: scale(.96) rotate(3deg); } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.6); } 100% { transform: scale(1); } }

/* Foto que "vuela" al carrito al agregar */
.volando { position: fixed; z-index: 50; margin: 0; border-radius: 12px; object-fit: contain; background: #fff; pointer-events: none; box-shadow: 0 8px 24px rgba(0,0,0,.25); }

/* Aviso "Agregado al carrito" */
.aviso {
  position: fixed; inset: auto auto 20px 50%; translate: -50% 0; margin: 0;
  display: flex; align-items: center; gap: 12px;
  width: min(420px, calc(100% - 24px)); padding: 10px 10px 10px 14px;
  border: 0; border-radius: 14px; background: #0f1115; color: #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
.aviso:popover-open { animation: subir .25s ease; }
@keyframes subir { from { opacity: 0; translate: -50% 16px; } }
.aviso-check { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 999px; background: var(--wa); font-weight: 700; }
.aviso-texto { flex: 1; display: flex; flex-direction: column; font-size: 14px; line-height: 1.3; min-width: 0; }
.aviso-texto span { opacity: .75; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aviso-ver { flex: none; border: 0; border-radius: 999px; padding: 8px 14px; background: #fff; color: var(--brand); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .btn-carrito, .btn-carrito.rebote, .btn-carrito:hover .ico-carrito, .badge.pop, .aviso:popover-open { animation: none; transition: none; }
}

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.intro h1 { margin: 8px 0 4px; font-size: clamp(22px, 4vw, 30px); }
.intro p { margin: 0 0 16px; color: var(--muted); }

.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filtros input, .filtros select {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); font: inherit; color: inherit;
}
.filtros input { flex: 1 1 240px; }
.chips { display: flex; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 8px 14px;
}
.chip[aria-pressed="true"] { background: var(--text); color: #fff; border-color: var(--text); }

.aviso-ejemplo { background: var(--wait-bg); color: var(--wait); padding: 8px 12px; border-radius: 10px; font-size: 14px; }
.vacio { color: var(--muted); text-align: center; padding: 40px 0; }

.grilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.card .foto { position: relative; width: 100%; padding: 0; border: 0; cursor: zoom-in; aspect-ratio: 4 / 3; background: #fff; border-bottom: 1px solid var(--line); display: grid; place-items: center; color: #9aa1ab; }
.card .foto img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.card .cuerpo { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card h3 { margin: 0; font-size: 16px; }
.link-nombre { all: unset; cursor: pointer; }
.link-nombre:hover { text-decoration: underline; }
.link-nombre:focus-visible, .card .foto:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.n-fotos {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(15,17,21,.75); color: #fff; font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
}
.card .meta { font-size: 13px; color: var(--muted); }
.card .precio { font-size: 18px; font-weight: 700; margin-top: auto; }
.estado { align-self: flex-start; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.estado.si { background: var(--ok-bg); color: var(--ok); }
.estado.no { background: var(--wait-bg); color: var(--wait); }
.btn-agregar {
  border: 0; border-radius: 10px; padding: 10px; font-weight: 600;
  background: var(--brand); color: var(--brand-ink);
}
.btn-agregar.agregado { background: var(--ok); }

.velo { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; }
.carrito {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 30;
  width: min(420px, 100%); background: var(--card);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .2s ease;
}
.carrito.abierto { transform: none; }
.carrito-cab { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.carrito-cab h2 { margin: 0; font-size: 18px; }
.cerrar { border: 0; background: none; font-size: 28px; line-height: 1; color: var(--muted); }
.carrito-items { list-style: none; margin: 0; padding: 8px 16px; overflow-y: auto; flex: 1; }
.carrito-items li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.carrito-items .nombre { font-weight: 600; }
.carrito-items .sub { font-size: 13px; color: var(--muted); }
.cantidad { display: flex; align-items: center; gap: 6px; }
.cantidad button { width: 30px; height: 30px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; }
.carrito-vacio { color: var(--muted); padding: 24px 0; text-align: center; }
.carrito-pie { padding: 14px 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.total { display: flex; justify-content: space-between; font-size: 18px; }
.nota { margin: 0; font-size: 12px; color: var(--muted); }
.btn-wa { border: 0; border-radius: 10px; padding: 12px; font-weight: 700; background: var(--wa); color: #fff; }
.btn-wa:disabled { opacity: .5; cursor: not-allowed; }
.btn-link { border: 0; background: none; color: var(--muted); text-decoration: underline; }
.pago-linea { display: flex; flex-direction: column; gap: 4px; }
.btn-pagar { border: 0; border-radius: 10px; padding: 12px; font-weight: 700; background: var(--brand); color: var(--brand-ink); }
.btn-pagar:disabled { opacity: .6; cursor: wait; }

.dialogo {
  width: min(520px, calc(100% - 24px)); max-height: calc(100% - 24px);
  border: 0; border-radius: var(--radius); padding: 20px 16px 16px; overflow-y: auto;
  background: var(--card); color: var(--text);
}
.dialogo::backdrop { background: rgba(0,0,0,.55); }
.dialogo h2 { margin: 0 0 10px; font-size: 20px; }
.dialogo form, .dialogo:not(:has(form)) { display: flex; flex-direction: column; gap: 10px; }
.dialogo .cerrar { position: absolute; top: 8px; right: 10px; }
.resumen-pago { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.resumen-pago li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.resumen-pago .total-pago { font-size: 16px; border-bottom: 0; padding-top: 8px; }
.campos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.campos label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.campos .ancho { grid-column: 1 / -1; }
.campos input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-weight: 400; color: inherit; background: var(--card);
}
@media (max-width: 480px) { .campos { grid-template-columns: 1fr; } }
.error { margin: 0; padding: 8px 12px; border-radius: 10px; background: #fde8e8; color: #9b1c1c; font-size: 14px; }

.detalle {
  width: min(640px, calc(100% - 24px)); max-height: calc(100% - 24px);
  padding: 0; border: 0; border-radius: var(--radius); overflow-y: auto;
  background: var(--card); color: var(--text);
}
.detalle::backdrop { background: rgba(0,0,0,.55); }
.detalle > .cerrar {
  position: absolute; top: 6px; right: 8px; z-index: 2;
  background: rgba(255,255,255,.9); border-radius: 999px; width: 36px; height: 36px;
}
.galeria { position: relative; background: #fff; }
.detalle-foto { aspect-ratio: 4 / 3; display: grid; place-items: center; color: #9aa1ab; }
.detalle-foto img { width: 100%; height: 100%; object-fit: contain; padding: 12px; }
.flecha {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: 0; border-radius: 999px;
  background: rgba(15,17,21,.6); color: #fff; font-size: 26px; line-height: 1;
}
.flecha.izq { left: 8px; }
.flecha.der { right: 8px; }
.miniaturas { display: flex; gap: 6px; padding: 8px 16px 0; overflow-x: auto; }
.miniaturas button { flex: 0 0 60px; height: 60px; padding: 2px; border: 2px solid var(--line); border-radius: 8px; background: #fff; }
.miniaturas button[aria-current="true"] { border-color: var(--brand); }
.miniaturas img { width: 100%; height: 100%; object-fit: contain; }
.detalle-info { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.detalle-info h2 { margin: 0; font-size: 20px; }
.detalle-info .meta { font-size: 13px; color: var(--muted); }
.detalle-info .precio { font-size: 22px; font-weight: 700; }

.pie { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px; }
