.photo-groups {
  display: grid;
  gap: 18px;
}

.photo-groups:empty {
  display: none;
}

.photo-month {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.photo-month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 15px;
}

.photo-month-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 720;
  text-transform: capitalize;
}

.photo-month-count {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--tint);
  color: var(--accent-strong);
  font-size: .78rem;
  font-weight: 650;
  white-space: nowrap;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(146px, 100%), 1fr));
  gap: 10px;
}

.photo-tile {
  display: grid;
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  padding: 0;
  color: var(--accent-strong);
  background: var(--tint);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.photo-tile img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
}

.photo-tile-name {
  position: absolute;
  inset: auto 0 0;
  overflow: hidden;
  padding: 19px 9px 7px;
  background: linear-gradient(transparent, #17172be8);
  color: #fff;
  font-size: .79rem;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
}

.photo-tile:is(:hover, :focus-visible) .photo-tile-name,
.photo-missing .photo-tile-name {
  opacity: 1;
}

.photo-missing {
  place-items: center;
}

.photo-missing .photo-tile-name {
  position: static;
  width: 100%;
  padding: 8px;
  color: var(--accent-strong);
  background: transparent;
  text-align: center;
}

.photo-empty {
  min-height: 350px;
  gap: 10px;
  padding: 28px 16px;
  border-radius: 20px;
  background: radial-gradient(ellipse at 50% 0, #f3edff, transparent 62%), var(--surface);
}

.photo-empty h2 {
  font-size: 1.25rem;
}

.photo-artwork {
  display: grid;
  position: relative;
  place-items: center;
  width: 106px;
  height: 92px;
  margin-bottom: 5px;
}

.photo-artwork-frame {
  position: absolute;
  width: 63px;
  height: 51px;
  border: 1px solid #d8cef9;
  border-radius: 12px;
  background: #e4dbff;
  transform: translate(-10px, -4px) rotate(-15deg);
}

.photo-artwork-front {
  overflow: hidden;
  background: linear-gradient(155deg, #faf7ff, #f1eaff);
  box-shadow: 0 9px 19px #3a237f28;
  transform: translate(10px, 4px) rotate(11deg);
}

.photo-artwork-front::before {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b69cf7;
}

.photo-artwork-front::after {
  content: "";
  position: absolute;
  bottom: 0;
  inset-inline: 0;
  height: 31px;
  background: linear-gradient(120deg, #a08cf5, #7558ee);
  clip-path: polygon(0 82%, 32% 25%, 51% 57%, 74% 9%, 100% 80%, 100% 100%, 0 100%);
}

.photo-empty-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
}

.photo-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.photo-status,
.photo-error {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .94rem;
  text-align: center;
}

.photo-status:empty,
.photo-error:empty {
  display: none;
}

.photo-error {
  color: var(--red);
}

dialog.photo-viewer {
  width: min(94vw, 980px);
  max-height: 94dvh;
  overflow: auto;
  padding: 16px;
  border-radius: 20px;
  background: var(--surface);
}

.photo-viewer::backdrop {
  background: #17172bdd;
}

.photo-viewer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.photo-viewer-details {
  min-width: 0;
}

.photo-viewer-header h2 {
  overflow-wrap: anywhere;
}

.photo-viewer .photo-caption {
  margin: 4px 0 0;
  font-size: .83rem;
}

.photo-viewer .photo-caption:empty {
  display: none;
}

.photo-stage {
  display: grid;
  place-items: center;
  min-height: min(180px, 25dvh);
  overflow: hidden;
  border-radius: 12px;
  background: #17172b;
}

.photo-stage img {
  display: block;
  max-width: 100%;
  max-height: 65dvh;
  object-fit: contain;
}

.photo-stage .photo-preview-error {
  color: #fff;
  padding: 10px;
  text-align: center;
}

.photo-viewer .photo-viewer-controls {
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.photo-viewer-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.photo-position {
  color: var(--muted);
  font-size: .83rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

@media (hover: none) {
  .photo-tile-name {
    opacity: 1;
  }
}

@media (max-width: 540px) {
  .photo-groups {
    gap: 12px;
  }

  .photo-month {
    padding: 12px;
    border-radius: 16px;
  }

  .photo-month-header {
    margin-bottom: 10px;
  }

  .photo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .photo-tile {
    border-radius: 9px;
  }

  .photo-tile-name {
    padding-inline: 5px;
    font-size: .69rem;
  }

  .photo-empty {
    min-height: 300px;
  }

  dialog.photo-viewer {
    padding: 10px;
    border-radius: 16px;
  }

  .photo-stage img {
    max-height: 57dvh;
  }

  .photo-viewer-nav,
  .photo-viewer-controls .primary {
    flex: 1 1 100%;
  }

  .photo-viewer-nav .secondary {
    padding-inline: 9px;
  }
}

