.tphrg-modal[hidden] {
  display: none;
}

.tphrg-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.tphrg-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.tphrg-dialog {
  position: relative;
  margin: 4vh auto;
  width: min(1100px, calc(100% - 2rem));
  max-height: 92vh;
  overflow: auto;
  border-radius: 1rem;
  background: #fff;
  padding: 1rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

.tphrg-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  border: 0;
  background: #111;
  color: #fff;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.tphrg-stage {
  position: relative;
  border-radius: 0.9rem;
  overflow: hidden;
  min-height: 280px;
  padding: 0 1rem;
  text-align: center;
}

.tphrg-main {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 68vh;
  object-fit: contain;
  margin: 0 auto;
}

.tphrg-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.tphrg-nav-prev {
  left: 0.75rem;
}

.tphrg-nav-next {
  right: 0.75rem;
}

.tphrg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.15rem 0.35rem;
  font-size: 0.875rem;
  color: #3f3f46;
}

.tphrg-thumbs {
  display: grid;
  grid-template-columns: repeat(var(--tphrg-thumb-cols, 4), minmax(0, 1fr));
  gap: 0.5rem;
}

.tphrg-thumb {
  border: 2px solid transparent;
  border-radius: 0.55rem;
  overflow: hidden;
  background: #fff;
  padding: 0;
  cursor: pointer;
}

.tphrg-thumb img {
  display: block;
  width: 100%;
  height: 138px;
  object-fit: cover;
}

.tphrg-thumb.is-active {
  border-color: #111;
}

body.tphrg-lock {
  overflow: hidden;
}

@media (max-width: 640px) {
  .tphrg-dialog {
    margin: 0;
    width: min(100%, 560px);
    max-height: calc(100vh - 1rem);
  }

  .tphrg-main {
    max-height: 56vh;
  }

  .tphrg-stage {
    padding: 0 0.5rem;
    min-height: 0;
  }

  .tphrg-meta {
    padding-top: 0.45rem;
    padding-bottom: 0.2rem;
  }

  .tphrg-thumbs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tphrg-thumb img {
    height: 96px;
  }
}

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

  .tphrg-thumb img {
    height: 88px;
  }
}
