pre,
pre code {
  border-radius: 0.75rem;
}

pre {
  background: rgba(15, 23, 42, 0.08);
  border: none;
  padding: .2rem;
  overflow-x: auto;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

pre code {
  display: block;
  background: transparent;
  padding: 0;
}

blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.04);
}

blockquote> :first-child {
  margin-top: 0;
}

blockquote> :last-child {
  margin-bottom: 0;
}

h1#gallery~table {
  width: 100%;
  border: none;
  border-collapse: separate;
  border-spacing: 1.25rem;
  margin-top: 1.25rem;
}

h1#gallery~table thead {
  display: none;
}

h1#gallery~table tbody,
h1#gallery~table tr,
h1#gallery~table td {
  border: none;
}

h1#gallery~table tbody tr {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

h1#gallery~table tbody tr:last-child {
  margin-bottom: 0;
}

h1#gallery~table td {
  padding: 1rem;
  border-radius: 1.25rem;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(2, 6, 23, 0.92));
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.55);
  outline: 1px solid rgba(148, 163, 184, 0.18);
}

h1#gallery~table td p {
  margin: 0;
}

h1#gallery~table td img {
  width: 100%;
  height: auto;
  border-radius: 0.9rem;
  outline: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.55);
}

.pf-gallery-caption,
figcaption {
  margin-top: 0.6rem;
  font-size: 1.2rem;
  font-style: italic;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.pf-gallery-caption {
  display: inline-flex;
}

figcaption {
  display: block;
}

@media (max-width: 900px) {
  h1#gallery~table tbody tr {
    grid-template-columns: 1fr;
  }
}

/* Prevent clipping of the "Copied" tooltip */
pre:has(.clip-button.tooltipped) {
  overflow-x: visible !important;
}

/* Image Modal Styles */
.image-modal-overlay {
  display: none;
  /* Hidden by default */
  position: fixed;
  /* Stay in place */
  z-index: 1000;
  /* Sit on top */
  padding-top: 0;
  /* Centered by flex */
  left: 0;
  top: 0;
  width: 100%;
  /* Full width */
  height: 100%;
  /* Full height */
  overflow: auto;
  /* Enable scroll if needed */
  background-color: rgb(0, 0, 0);
  /* Fallback color */
  background-color: rgba(0, 0, 0, 0.85);
  /* Black w/ opacity */
  justify-content: center;
  align-items: center;
  flex-direction: column;
  backdrop-filter: blur(5px);
}

.image-modal-wrapper {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  justify-content: center;
  align-items: center;
  animation-name: zoom;
  animation-duration: 0.3s;
}

.image-modal-content {
  display: block;
  max-width: 100%;
  max-height: 90vh;
  /* Ensure it fits in viewport */
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

@keyframes zoom {
  from {
    transform: scale(0.95);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.image-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  background-color: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
  z-index: 1001;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.image-modal-close:hover {
  background-color: rgba(255, 255, 255, 0.9);
  color: #000;
  transform: scale(1.1);
}

/* Add cursor pointer to images in content */
.content img {
  cursor: pointer;
  transition: 0.3s;
}

.content img:hover {
  opacity: 0.9;
}

/* Image Modal Caption */
#caption {
  margin-top: 16px;
  padding: 0 20px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 300;
  font-style: italic;
  letter-spacing: 0.05em;
  color: transparent;
  background: linear-gradient(135deg, #e2e8f0 0%, #94a3b8 50%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: 0 0 30px rgba(148, 163, 184, 0.3);
  animation: captionFadeIn 0.4s ease-out;
  max-width: 80%;
}

@keyframes captionFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Image Modal Navigation Buttons */
.image-modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 24px;
  cursor: pointer;
  z-index: 1002;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease, background-color 0.2s ease, transform 0.2s ease;
}

@media (hover: hover) {
  .image-modal-overlay:hover .image-modal-nav {
    opacity: 0.7;
  }

  .image-modal-nav:hover {
    opacity: 1 !important;
    background-color: rgba(255, 255, 255, 0.9);
    color: #000;
    transform: translateY(-50%) scale(1.1);
  }
}

.image-modal-prev {
  left: 20px;
}

.image-modal-next {
  right: 20px;
}

/* Touch device: fade out nav buttons when inactive */
@media (hover: none) and (pointer: coarse) {
  .image-modal-nav {
    opacity: 0;
    /* Default invisible, managed by JS classes */
    transition: opacity 0.5s ease;
  }

  .user-active .image-modal-nav {
    opacity: 0.7;
  }

  /* Ensure they are fully visible if tapped directly, though JS handles 'user-active' */
  .image-modal-nav:active {
    opacity: 1;
  }
}

/* Image Modal Hint */
.image-modal-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: rgba(255, 255, 255, 0.9);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 1001;
  pointer-events: none;
  animation: hintPulse 2s ease-in-out infinite;
}

.image-modal-hint.fading {
  animation: hintFadeOut 0.5s ease-out forwards;
}

@keyframes hintPulse {

  0%,
  100% {
    opacity: 0.8;
  }

  50% {
    opacity: 1;
  }
}

@keyframes hintFadeOut {
  to {
    opacity: 0;
  }
}