html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  font-family: Arial, sans-serif;
  overflow: auto; /* Allow scroll for large base flowchart */
}

/* === Main container === */
#app {
  width: 100%;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* === Flowchart container === */
#flowContainer {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: visible;
}

#flowImg {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* === Hotspots === */
.hotspot {
  position: absolute;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 5;
}

/* Uncomment to debug positions */
/*
.hotspot { background: rgba(0, 128, 255, 0.25); }
*/

/* === Overlay === */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#overlay.active {
  display: flex;
  opacity: 1;
}

/* === Overlay inner box === */
#overlay-inner {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 2vh 2vw; /* small margins around the figure */
  box-sizing: border-box;
}

/* === Popup image (linked figure) === */
#overlay-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 96vw;   /* never exceed 96% of viewport width */
  max-height: 96vh;  /* never exceed 96% of viewport height */
  object-fit: contain;
  border-radius: 8px;
  background: white;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.6);
}

/* === Toolbar and buttons === */
#overlay-toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 10px;
}

#closeBtn, #backBtn {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 6px 10px;
  transition: background 0.2s ease;
}

#closeBtn:hover, #backBtn:hover {
  background: #fff;
}

.navBtn {
  background: #007bff;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.navBtn:hover {
  background: #0056b3;
}
