/* =================================
 Flex Gallery
================================= */

.flex_gallery{
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: stretch;
  margin: 0;
  width: 100%;
}

.flex_gallery li,.flex_gallery ul li{
  padding: 0px 10px 0px 0px;
  list-style: none;
  text-align: center;
  max-width: 60%;
    line-height: 1.3em;
    margin: auto;
}

.flex_gallery li img, .flex_gallery ul li img{
width:100%;
height:auto;
border-radius:4px;
border:1px solid #DBDBDB;
max-width: 480px;
}

.flex_gallery .wp-caption{
width:100%!important;
}

.flex_gallery .wp-caption-text{
margin:0.2em 0 1em;
color:#000;
line-height:1.4;
}

/* tablet */

@media (max-width:768px){

.flex_gallery{
    display: flex;
    flex-wrap: wrap;
    align-content: space-around;
}

.flex_gallery li,.flex_gallery ul li{
flex:0 0 48%;
    padding: 0px 2px 10px 0px;
}

}

/* smartphone */

@media (max-width:520px){

.flex_gallery li{
    display: flex;
    flex-wrap: wrap;
    align-content: space-around;
}
.flex_gallery li img, .flex_gallery ul li img{
    flex-basis: 49%;
    padding: 0px 2px 10px 0px;
max-width: 100%;
}
}

/* small smartphone */

@media (max-width:400px){

.flex_gallery li img, .flex_gallery ul li img{
    flex-basis: 100%;
    padding: 0px 2px 10px 0px;
max-width: 100%;
}

}

.wp-caption-text {
    font-size: .9em;
    margin-top: .7em;
    opacity: 1;
    text-align: center;
}

/* =================================
 PDF Gallery（可変 + SP1カラム）
================================= */

.pdf_gallery{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

/* PDF本体（必須） */
.pdf_item .pdfemb-viewer{
  width: 100% !important;
  max-width: 100% !important;
}

.pdf_item .pdfemb-pagescontainer{
  width: 100% !important;
}

.pdf_item canvas{
  width: 100% !important;
  height: auto !important;
}

/* キャプション */
.pdf_item .wp-caption-text{
  margin-top: 0.5rem;
  font-size: 0.9rem;
  text-align: center;
}

/* =========================
 Tablet（少し詰める）
========================= */
@media (max-width:768px){
  .pdf_gallery{
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
  }
}

/* =========================
 Smartphone（1カラム固定）
========================= */
@media (max-width:520px){
  .pdf_gallery{
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}
@media (max-width:520px){
  .pdf_item{
    padding: 0.5rem;
  }
}

/* =========================
 Small SP（余白さらに調整）
========================= */
@media (max-width:400px){
  .pdf_gallery{
    gap: 0.8rem;
  }
}