html:has(.cv-dialog[open]) {
  overflow: hidden;
}

.cv-dialog {
  position: fixed;
  inset: 0;
  width: min(48rem, calc(100% - 2rem));
  height: min(56rem, calc(100vh - 2rem));
  height: min(56rem, calc(100dvh - 2rem));
  max-width: none;
  max-height: none;
  padding: 0;
  margin: auto;
  overflow: hidden;
  border: 1px solid #363636;
  border-radius: .625rem;
  background: #111;
  color: #fff;
  box-shadow: 0 1.5rem 5rem #0009;
}

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

.cv-dialog::backdrop {
  background: rgb(0 0 0 / 76%);
  backdrop-filter: blur(6px);
}

.cv-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .625rem .75rem .625rem 1.125rem;
  border-bottom: 1px solid #303030;
}

.cv-dialog h2 {
  margin: 0;
  font-size: .875rem;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: .035em;
}

.cv-dialog-actions {
  display: flex;
  align-items: center;
  gap: .375rem;
  margin: 0;
}

.cv-download,
.cv-close {
  display: inline-grid;
  place-items: center;
  min-height: 2.75rem;
  border: 0;
  border-radius: .375rem;
  font: inherit;
  cursor: pointer;
}

.cv-download {
  padding-inline: .875rem;
  background: #f1f1f1;
  color: #0a0a0a;
  font-size: .875rem;
  white-space: nowrap;
}

.cv-download:hover,
.cv-download:focus-visible {
  background: #dcdcdc;
  text-decoration: none;
}

.cv-close {
  width: 2.75rem;
  padding: 0;
  background: transparent;
  color: #fff;
  font-size: 1.625rem;
  line-height: 1;
}

.cv-close:hover {
  background: #292929;
}

.cv-dialog :focus-visible {
  outline: 1px solid #fff;
  outline-offset: 2px;
}

.cv-preview {
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(.625rem, 2.7vw, 1.5rem);
  background: #191919;
}

.cv-preview:focus-visible {
  outline-offset: -3px;
}

.cv-preview img {
  display: block;
  width: 100%;
  height: auto;
  margin-inline: auto;
  background: #fff;
}

@media (max-width: 600px) {
  .cv-dialog {
    width: calc(100% - 1rem);
    height: calc(100dvh - 1rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .cv-dialog-header {
    padding: .375rem .375rem .375rem .75rem;
  }
}
