.grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.ph{
  display:block;
  width:100%;
  border-radius: 16px;
  overflow:hidden;
  border: 1px solid rgba(47,42,38,0.10);
  background: rgba(255,255,255,0.8);
  box-shadow: 0 10px 22px rgba(0,0,0,0.05);
  transition: transform 140ms ease, box-shadow 180ms ease;
  text-decoration:none;
  cursor:pointer;
  padding:0;
  text-align:left;
  appearance:none;
  -webkit-appearance:none;
}

.ph:hover{
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(0,0,0,0.08);
}

.ph:focus-visible{
  outline: 2px solid rgba(47,42,38,0.28);
  outline-offset: 2px;
}

.ph img{
  width:100%;
  height: 260px;
  object-fit: cover;
  display:block;
}


.cap{
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* page scroll lock while lightbox is open */
body.lightbox-open{
  overflow:hidden;
}

/* lightbox */
dialog#lightbox{
  width: min(1100px, 96vw);
  max-width: 96vw;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 18px;
  padding: 10px;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 30px 80px rgba(0,0,0,0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

dialog#lightbox::backdrop{
  background: rgba(0,0,0,0.55);
}

.lbShell{
  display:flex;
  flex-direction:column;
  gap: 6px;
}

.lbTop{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px 10px;
}

.lbTopRight{
  display:flex;
  align-items:center;
  gap: 10px;
}

.lbTitle{
  margin:0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.lbCount{
  margin:0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.lbClose{
  border: 1px solid rgba(47,42,38,0.12);
  background: rgba(255,255,255,0.85);
  border-radius: 999px;
  padding: 8px 10px;
  cursor:pointer;
  font: inherit;
  font-size: 13px;
  line-height: 1;
}

.lbBody{
  display:grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items:center;
  gap: 10px;
}

.lbFigure{
  margin:0;
  display:flex;
  align-items:center;
  justify-content:center;
  min-width:0;
}

.lbImg{
  width: 100%;
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 12px;
  display:block;
  background: rgba(255,255,255,0.7);
}

.lbNav{
  width: 44px;
  height: 44px;
  border: 1px solid rgba(47,42,38,0.12);
  background: rgba(255,255,255,0.88);
  border-radius: 999px;
  cursor:pointer;
  font: inherit;
  font-size: 28px;
  line-height: 1;
  display:flex;
  align-items:center;
  justify-content:center;
  color: #2f2a26;
  margin: 0 auto;
  box-shadow: 0 10px 22px rgba(0,0,0,0.06);
}

.lbNav:hover:not(:disabled),
.lbClose:hover{
  background: rgba(255,255,255,0.98);
}

.lbNav:disabled{
  opacity: 0.35;
  cursor: default;
  box-shadow:none;
}

.lbNav:focus-visible,
.lbClose:focus-visible{
  outline: 2px solid rgba(47,42,38,0.28);
  outline-offset: 2px;
}

@media (max-width: 860px){
  .grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ph img{
    height: 200px;
  }

  .lbBody{
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    gap: 8px;
  }

  .lbNav{
    width: 40px;
    height: 40px;
    font-size: 24px;
  }
}

@media (max-width: 520px){
  .grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ph img{
    height: 160px;
  }

  dialog#lightbox{
    width: 100vw;
    max-width: 100vw;
    border-radius: 0;
    padding: 8px;
    border: 0;
    min-height: 100dvh;
  }

  .lbTop{
    padding: 6px 4px 8px;
  }

  .lbBody{
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    gap: 6px;
  }

  .lbNav{
    width: 36px;
    height: 36px;
    font-size: 22px;
  }

  .lbImg{
    max-height: 72dvh;
  }

  .lbClose{
    padding: 8px 9px;
    font-size: 12px;
  }
}

.credit{
  margin-top: 10px;
  color: #7a6f66;
}

.credit a{
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.credit a:hover{
  opacity: 0.8;
}
