.yutd-gallery-clickable {
  cursor: zoom-in;
}

.yutd-gallery-modal-open {
  overflow: hidden;
}

.yutd-gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: none;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0;
  background: rgba(0, 0, 0, 0.78);
  font-family: Arial, sans-serif;
}

.yutd-gallery-modal.is-open {
  display: flex;
}

.yutd-gallery-modal__dialog {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  box-sizing: border-box;
  background: #fff;
  border: 0;
  box-shadow: none;
}

.yutd-gallery-modal__stage {
  position: relative;
  min-height: 0;
  background: #f4f4f4;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  cursor: grab;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.yutd-gallery-modal__stage.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.yutd-gallery-modal__image {
  display: block;
  max-width: none;
  max-height: none;
  width: 100%;
  height: auto;
  object-fit: initial;
  opacity: 1;
  transition: opacity 280ms ease;
  user-select: none;
  -webkit-user-drag: none;
}

.yutd-gallery-modal.is-loading .yutd-gallery-modal__image {
  opacity: 0;
  transition-duration: 0ms;
}

.yutd-gallery-modal__loading {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 1;
  box-sizing: border-box;
  min-width: 210px;
  padding: 12px 18px;
  transform: translate(-50%, -50%);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.94);
  color: #222;
  font-size: 15px;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  display: none;
}

.yutd-gallery-modal.is-loading .yutd-gallery-modal__loading {
  display: block;
}

.yutd-gallery-modal__caption {
  padding: 14px 18px 16px;
  color: #222;
  background: #fff;
}

.yutd-gallery-modal__title {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.25;
  font-weight: bold;
}

.yutd-gallery-modal__title a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.yutd-gallery-modal__description {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: #555;
}

.yutd-gallery-modal__document {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  color: #0a672d;
  text-decoration: underline;
}

.yutd-gallery-modal__counter {
  position: fixed;
  z-index: 3;
  left: 12px;
  top: 12px;
  padding: 4px 8px;
  color: #fff;
  background: rgba(0, 0, 0, 0.62);
  font-size: 12px;
  line-height: 1.2;
}

.yutd-gallery-modal__close,
.yutd-gallery-modal__nav {
  position: fixed;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-weight: bold;
  line-height: 1;
}

.yutd-gallery-modal__close {
  right: 12px;
  top: 12px;
  width: 38px;
  height: 38px;
  font-size: 28px;
}

.yutd-gallery-modal__nav {
  top: 50%;
  width: 44px;
  height: 58px;
  transform: translateY(-50%);
  font-size: 38px;
}

.yutd-gallery-modal__nav--prev {
  left: 12px;
}

.yutd-gallery-modal__nav--next {
  right: 12px;
}

.yutd-gallery-modal__close:hover,
.yutd-gallery-modal__nav:hover,
.yutd-gallery-modal__close:focus,
.yutd-gallery-modal__nav:focus {
  background: rgba(0, 0, 0, 0.9);
  outline: 2px solid #fff;
  outline-offset: 1px;
}

.yutd-gallery-modal__nav[disabled] {
  display: none;
}

@media (max-width: 700px) {
  .yutd-gallery-modal {
    padding: 0;
  }

  .yutd-gallery-modal__dialog {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
  }

  .yutd-gallery-modal__stage {
    min-height: 0;
  }

  .yutd-gallery-modal__image {
    max-height: none;
  }

  .yutd-gallery-modal__caption {
    padding: 12px 14px;
  }

  .yutd-gallery-modal__title {
    font-size: 16px;
  }

  .yutd-gallery-modal__nav {
    width: 38px;
    height: 50px;
    font-size: 32px;
  }
}

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