/* Keep the complete photo and close control inside the visible screen. */
#viewer {
  width: min(960px, calc(100vw - 32px));
  height: min(900px, calc(100vh - 32px));
  height: min(900px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  padding: 12px 16px 16px;
  overflow: hidden;
  border-radius: 12px;
}
#viewer[open] {
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr) auto;
  gap: 12px;
}
#viewer .close {
  position: static;
  justify-self: end;
  margin: 0;
  width: 44px;
  height: 44px;
}
#viewer #full-menu {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  margin: 0;
  object-fit: contain;
}
#viewer #menu-book {
  justify-self: center;
  margin: 0;
  padding: 12px 20px;
}
@media (max-width: 560px), (max-height: 500px) {
  #viewer {
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
    height: calc(100dvh - 20px);
    padding: 8px 10px 10px;
  }
  #viewer[open] { gap: 8px; }
  #viewer #menu-book { padding: 8px 14px; font-size: 12px; }
}
