body {
  font-family: Arial, sans-serif;
  margin: 0;
  background-color: #f6f8fa;
  color: #222;
}

header {
  text-align: center;
  padding: 2rem 1rem;
  background: linear-gradient(45deg, #5a61ff, #ae52f7);
  color: white;
}

.grid-categorias {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.5rem;
  padding: 2rem;
  max-width: 1100px;
  margin: 0 auto;
}

.categoria {
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: transform 0.2s ease;
  text-align: center;
  padding: 1.5rem 1rem;
}

.categoria:hover {
  transform: translateY(-5px);
}

.categoria img {
  width: 40px;
  height: 40px;
  margin-bottom: 0.5rem;
}

.categoria h2 {
  margin: 0.5rem 0;
  font-size: 1rem;
  color: #333;
}

.categoria span {
  color: #666;
  font-size: 0.9rem;
}

footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
  color: #888;
}

a.categoria {
  text-decoration: none;
  color: inherit;
  display: block;
}

.enlace-descarga {
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s;
}

.enlace-descarga:hover {
  transform: scale(1.02);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
}

.portada-horizontal {
  width: 100%;
  height: auto;
  max-height: 160px;
  object-fit: contain;
  border-radius: 4px;
  margin-bottom: 10px;
}

.enlace-descarga img.portada-horizontal {
  width: 100%;
  max-width: 280px;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  margin: 0 auto 12px auto;
  border-radius: 6px;
}

.categoria a,
.categoria a:visited {
  text-decoration: none !important;
  color: inherit !important;
}

.tarjeta-libro {
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s ease;
  text-decoration: none;
  color: inherit;
  height: 100%;
}

.tarjeta-libro {
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s ease;
  text-decoration: none;
  color: inherit;
  height: 100%;
}

.tarjeta-libro:hover {
  transform: translateY(-4px);
}

.contenedor-imagen {
  width: 100%;
  aspect-ratio: 3 / 4; /* Control visual directo */
  overflow: hidden;
  background: #fff;
}

.imagen-portada {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Llena todo el espacio, sin bordes blancos */
  display: block;
}

.contenido-libro {
  padding: 0.8rem;
  text-align: center;
}

.contenido-libro h2 {
  font-size: 1rem;
  margin: 0.5rem 0 0.2rem 0;
  color: #333;
}

.contenido-libro p {
  font-size: 0.9rem;
  color: #666;
  margin: 0;
}

.tarjeta-libro {
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s ease;
  text-decoration: none;
  color: inherit;
  height: 100%;
}

.tarjeta-libro:hover {
  transform: translateY(-4px);
}

.contenedor-imagen {
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #fff;
}

.imagen-portada {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.contenido-libro {
  padding: 0.8rem;
  text-align: center;
}

.contenido-libro h2 {
  font-size: 1rem;
  margin: 0.5rem 0 0.2rem 0;
  color: #333;
}

.contenido-libro p {
  font-size: 0.9rem;
  color: #666;
  margin: 0;
}

.boton-descarga {
  display: inline-block;
  margin-top: 10px;
  padding: 0.5rem 1.2rem;
  background-color: #e53935;
  color: white;
  font-weight: bold;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.9rem;
  transition: background-color 0.2s ease;
}

.boton-descarga:hover {
  background-color: #c62828;
}

.boton-volver {
  display: inline-block;
  margin: 1rem 2rem;
  padding: 0.5rem 1.2rem;
  background-color: #ddd;
  color: #333;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.9rem;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.boton-volver:hover {
  background-color: #bbb;
  color: black;
}

