.tp-gallery-item {
  display: inline-flex;
  max-width: 200px;
  max-height: 150px;
  margin: 2px;
  overflow: hidden;
  line-height: 0;
  vertical-align: middle;
  text-decoration: none;
  background: color-mix(in srgb, var(--theme-accent-color, #999) 5%, var(--theme-color, #e9ecef));
  border: 2px solid color-mix(in srgb, var(--theme-accent-color, #999) 22%, transparent);
  border-radius: 8px;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.tp-gallery-item:hover,
.tp-gallery-item:focus {
  border-color: color-mix(in srgb, var(--theme-accent-color, #999) 65%, transparent);
  box-shadow: 0 3px 12px color-mix(in srgb, var(--theme-accent-color, #999) 18%, transparent);
  text-decoration: none;
}

.tp-gallery-item:focus {
  outline: 2px solid var(--theme-accent-color, #777);
  outline-offset: 2px;
}

.tp-gallery-item:active {
  transform: scale(.98);
}

.tp-gallery-item img.thumb {
  display: block;
  width: auto;
  height: auto;
  max-width: 196px;
  max-height: 146px;
  border: 0;
  object-fit: contain;
}

.tp-thumb-strip:not(.post-align) {
  display: inline;
}

#chat .tp-gallery-item {
  max-width: 120px;
  max-height: 120px;
}

#chat .tp-gallery-item img.thumb {
  max-width: 116px;
  max-height: 116px;
}

.glightbox-clean .gclose,
.glightbox-clean .gnext,
.glightbox-clean .gprev {
  background: color-mix(in srgb, var(--theme-accent-color, #777) 30%, rgba(0, 0, 0, .72));
  border-radius: 50%;
}

.glightbox-clean .gclose:hover,
.glightbox-clean .gnext:hover,
.glightbox-clean .gprev:hover,
.glightbox-clean .gclose:focus,
.glightbox-clean .gnext:focus,
.glightbox-clean .gprev:focus {
  background: color-mix(in srgb, var(--theme-accent-color, #999) 55%, rgba(0, 0, 0, .72));
}

.glightbox-container .gbtn:focus {
  outline: 2px solid var(--theme-accent-color, #fff);
  outline-offset: 2px;
}

.tp-gallery-counter {
  position: absolute;
  z-index: 100000;
  top: max(15px, env(safe-area-inset-top));
  left: 50%;
  min-width: 58px;
  padding: 6px 12px;
  color: #fff;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
  pointer-events: none;
  background: rgba(0, 0, 0, .62);
  border: 1px solid color-mix(in srgb, var(--theme-accent-color, #999) 35%, transparent);
  border-radius: 999px;
  transform: translateX(-50%);
}

@media (max-width: 767px) {
  .tp-thumb-strip {
    display: flex !important;
    width: 100%;
    max-width: 100%;
    padding: 4px 2px 10px;
    margin: 6px 0;
    gap: 8px;
    align-items: center;
    justify-content: flex-start !important;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    text-align: left !important;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 2px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
  }

  .tp-thumb-strip > .tp-gallery-item {
    flex: 0 0 132px;
    width: 132px;
    height: 96px;
    max-width: none;
    max-height: none;
    margin: 0;
    scroll-snap-align: start;
  }

  .tp-thumb-strip > .tp-gallery-item img.thumb {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
  }

  #chat .tp-thumb-strip > .tp-gallery-item {
    flex-basis: 112px;
    width: 112px;
    height: 84px;
    max-width: none;
    max-height: none;
  }

  #chat .tp-thumb-strip > .tp-gallery-item img.thumb {
    max-width: none;
    max-height: none;
  }

  .glightbox-clean .gprev {
    left: max(8px, env(safe-area-inset-left));
  }

  .glightbox-clean .gnext {
    right: max(8px, env(safe-area-inset-right));
  }

  .glightbox-clean .gclose {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
  }
}

@media (prefers-reduced-motion: reduce) {
  .tp-gallery-item {
    transition: none;
  }
}
