:root {
  --focus-outline-color: #0000ff;
}

/* Local skeleton so it works even if CSS changes */
#imageContainer {
  position: relative;
}

#loader.loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 2;
  pointer-events: none;
}

#loader[hidden] {
  display: none !important;
}

#uiSkeletonOverlay[hidden] {
  display: none !important;
}

#uiSkeletonOverlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: none;
  overflow: hidden;
}

/* Make overlay mimic the real DOM structure */
#uiSkeletonOverlay .header,
#uiSkeletonOverlay .mySlides,
#uiSkeletonOverlay .imageContainer,
#uiSkeletonOverlay .zoom-container,
#uiSkeletonOverlay .bottom-container,
#uiSkeletonOverlay .bottom-content {
  pointer-events: none;
}

/* Layout rules to mimic the real viewer sizing (since IDs differ) */
#uiSkeletonOverlay #imageViewerContainerSkeleton {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#uiSkeletonOverlay #imageViewerContainerSkeleton .header {
  flex: 0 0 auto;
}

#uiSkeletonOverlay #imageViewerContainerSkeleton .mySlides {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#uiSkeletonOverlay #imageContainerSkeleton {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#uiSkeletonOverlay #imageContainerSkeleton .image-zoom-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

#uiSkeletonOverlay .skl-image-area {
  flex: 1 1 auto;
  min-height: 240px;
}

.skeleton-block {
  border-radius: 4px;
  background: linear-gradient(
    110deg,
    rgba(230, 230, 230, 0.92) 8%,
    rgba(245, 245, 245, 0.98) 18%,
    rgba(230, 230, 230, 0.92) 33%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.1s linear infinite;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

/* Skeleton pieces sized to actual controls */
.skl-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.skl-text {
  height: 16px;
  width: min(520px, 48vw);
}

.skl-sphere-name {
  height: 16px;
  width: min(260px, 40vw);
}

.skl-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
}

.skl-btn-icon {
  height: 18px;
  width: 18px;
  border-radius: 4px;
}

.skl-btn-text {
  height: 14px;
  width: 70px;
  border-radius: 4px;
}

.skl-nav-group {
  height: 30px;
  width: 232px;
  border-radius: 6px;
}

.skl-index-num {
  height: 14px;
  width: 14px;
  border-radius: 4px;
}

.skl-index-slash {
  height: 14px;
  width: 10px;
  border-radius: 4px;
}

.skl-zoom-icon {
  height: 25px;
  width: 25px;
  border-radius: 4px;
}

.skl-action-btn {
  height: 32px;
  width: 92px;
  border-radius: 4px;
}

.skl-action-btn.wide {
  width: 104px;
}

.skl-trash {
  height: 22px;
  width: 22px;
  border-radius: 4px;
}

.skl-image-area {
  width: 100%;
  height: 100%;
  border-radius: 4px;
}

.skeleton-wrapper {
  width: min(860px, 92vw);
}

.skeleton-content {
  height: min(520px, 62vh);
  border-radius: 16px;
  background: transparent;
}

.skeleton-hint {
  margin-top: 12px;
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: rgba(0, 0, 0, 0.65);
  text-align: center;
}

.skeleton-error {
  margin-top: 10px;
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #d7273e;
  text-align: center;
  display: none;
}

#loader[data-state="error"] .skeleton-error {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--focus-outline-color);
  outline-offset: 2px;
  border-radius: 2px;
}

@keyframes skeleton-shimmer {
  to {
    background-position-x: -200%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-block {
    animation: none;
  }
}
