button.image-detail-trigger {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: inherit;
  cursor: zoom-in;
}

button.image-detail-trigger:focus-visible {
  outline: 3px solid var(--focus, #a7deff);
  outline-offset: -4px;
}

button.image-detail-trigger img {
  display: block;
}

body.image-detail-open {
  overflow: hidden;
}

.image-detail-dialog {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: min(1400px, calc(100vw - 32px));
  height: min(960px, calc(100dvh - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line, #526377);
  border-radius: 16px;
  background: var(--surface-solid, #172938);
  color: var(--ink, #f5f9fd);
  box-shadow: 0 20px 80px rgba(0, 0, 0, .5);
}

.image-detail-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.image-detail-dialog::backdrop {
  background: rgba(2, 7, 14, .86);
}

.image-detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line, #526377);
}

.image-detail-toolbar h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
}

.image-detail-actions {
  display: flex;
  gap: 8px;
}

.image-detail-actions button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line, #526377);
  border-radius: 8px;
  background: var(--surface, #172938);
  color: var(--ink, #f5f9fd);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.image-detail-actions button:hover {
  background: var(--hover, #32485b);
}

.image-detail-actions button:disabled {
  opacity: .5;
  cursor: default;
}

.image-detail-actions button:focus-visible,
.image-detail-stage:focus-visible {
  outline: 3px solid var(--focus, #a7deff);
  outline-offset: -4px;
}

.image-detail-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y pinch-zoom;
  background: #080d15;
}

.image-detail-image {
  display: block;
  flex: none;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  object-fit: contain;
}

.image-detail-dialog.is-zoomed .image-detail-stage {
  align-items: flex-start;
  justify-content: flex-start;
}

.image-detail-dialog.is-zoomed .image-detail-image {
  width: auto;
  height: auto;
}

.image-detail-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  color: var(--muted, #edf3f8);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.image-detail-image[hidden],
.image-detail-status[hidden],
.image-detail-footer p[hidden] {
  display: none;
}

.image-detail-footer {
  max-height: min(26dvh, 160px);
  padding: 12px 16px;
  overflow-y: auto;
  border-top: 1px solid var(--line, #526377);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.image-detail-footer p {
  margin: 0;
}

.image-detail-footer p + p {
  margin-top: 5px;
}

#image-detail-caption,
#image-detail-instructions {
  color: var(--muted, #edf3f8);
}

#image-detail-instructions {
  font-size: 11px;
}

@media (max-width: 480px) {
  .image-detail-dialog {
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 12px;
  }

  .image-detail-toolbar {
    gap: 6px 10px;
    padding: 8px 10px;
  }

  .image-detail-toolbar h2 {
    font-size: 13px;
  }

  .image-detail-actions {
    gap: 6px;
  }

  .image-detail-actions button {
    padding-inline: 11px;
  }

  .image-detail-footer {
    padding: 10px 12px;
    font-size: 11px;
  }
}
