html.file-preview-open,
body.file-preview-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

.file-preview-layer {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  background: rgba(12, 34, 28, .74);
  backdrop-filter: blur(5px);
}

.file-preview {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(920px, 100%);
  height: min(88dvh, 860px);
  max-height: calc(100dvh - 24px);
  overflow: hidden;
  border: 1px solid #d6e0da;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(5, 25, 20, .36);
}

.file-preview header {
  display: flex;
  min-width: 0;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 8px 16px;
  color: #173d33;
  border-bottom: 1px solid #e0e7e3;
  background: #f7faf8;
}

.file-preview header strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview__close {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  padding: 0;
  place-items: center;
  color: #315f51;
  border: 1px solid #d3ded8;
  border-radius: 50%;
  background: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.file-preview__frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #edf1ee;
}

.file-preview__image-wrap {
  display: flex;
  min-width: 0;
  min-height: 0;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y pinch-zoom;
  background: #edf1ee;
}

.file-preview__image {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  min-height: 1px;
  margin: 0 auto;
  object-fit: contain;
  background: #fff;
}

.file-preview__error {
  align-self: center;
  margin: auto;
  padding: 20px;
  color: #8f423e;
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}

@media (max-width: 700px) {
  .file-preview-layer {
    align-items: stretch;
    padding: 0;
  }

  .file-preview {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .file-preview header {
    min-height: calc(56px + env(safe-area-inset-top));
    padding:
      calc(8px + env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      8px
      max(14px, env(safe-area-inset-left));
  }

  .file-preview__image-wrap {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .file-preview__image {
    width: 100%;
    max-width: 100%;
  }
}
