* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  /* background: #fafafa; */
}

/* Hide nav and viewer initially */
[section="view"] {
  display: none;
}

/* Show nav and viewer when intro is hidden */
[section="view"].active {
  display: block;
}

/* Hide intro when viewing sketchbook */
#intro.hidden {
  display: none;
}

#nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 120px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#nav::after {
  content: '';
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(64px * (var(--nav-count) - 1) + 16px * (var(--nav-count) - 1));
  height: 1px;
  background: #ccc;
}

#nav-inner {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 20px;
  max-width: 100%;
}

.nav-thumb {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  cursor: pointer;
  border-radius: 4px;
  position: relative;
}

.nav-thumb::after {
  content: '';
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #ccc;
  background: white;
  transition: background-color 0.2s ease;
  z-index: 2;
}

.nav-thumb.active::after {
  background: black;
  border-color: black;
}

.nav-thumb:hover::after {
  background: #888;
}


.nav-thumb.active {
  border-color: #007aff;
}

.nav-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#viewer {
  margin-top: 120px;
  height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
}

#viewer-inner {
  display: flex;
  gap: 40px;
  overflow-x: auto;
  height: 100%;
  padding: 0 40px 0 calc(40px + 50vw);
  align-items: center;
  scroll-behavior: smooth;
}

.page-container {
  flex-shrink: 0;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.page-image {
  max-height: 100%;
  max-width: calc(100vw - 80px);
  cursor: pointer;
  border-radius: 4px;
  background: white;
  object-fit: contain;
}

.page-captions {
  position: absolute;
  bottom: -60px;
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: calc(100vw - 80px);
  font-size: 12px;
  color: #666;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.page-container:hover .page-captions {
  opacity: 1;
}

.caption-left {
  text-align: left;
  width: 30%;
  padding-right: 10px;
}

.caption-right {
  text-align: right;
  width: 30%;
  padding-left: 10px;
  margin-left: auto;
}

#nav-inner::-webkit-scrollbar,
#viewer-inner::-webkit-scrollbar {
  height: 0;
  width: 0;
}

#nav-inner,
#viewer-inner {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

@media (max-width: 768px) {
  #nav {
    height: 80px;
  }
  
  .nav-thumb {
    width: 48px;
    height: 48px;
  }
  
  .nav-thumb::after {
    width: 8px;
    height: 8px;
    bottom: -16px;
  }
  
  #nav::after {
    bottom: 12px;
    width: calc(48px * var(--nav-count) + 12px * (var(--nav-count) - 1) + 24px);
  }
  
  #nav-inner {
    gap: 12px;
    padding: 16px;
  }
  
  #viewer {
    margin-top: 80px;
    height: calc(100vh - 80px);
    padding: 10px 0 0 0;
  }
  
  #viewer-inner {
    flex-direction: column;
    gap: 20px;
    padding: 0 20px;
    overflow-y: auto;
    overflow-x: hidden;
    align-items: stretch;
  }
  
  .page-container {
    width: 100%;
  }
  
  .page-image {
    width: 100%;
    max-height: calc(100vh - 160px);
    height: auto;
    object-fit: contain;
  }
  
  .page-captions {
    flex-direction: column;
    gap: 8px;
    max-width: 100%;
    padding: 0 20px;
  }
  
  .caption-left,
  .caption-right {
    text-align: left;
    padding: 0;
  }
}

/* Introduction section styles */
#intro {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  z-index: 200;
}

#intro-inner {
  width: 90%;
  max-width: 900px;
  border-radius: 8px;
  display: flex;
  min-height: 400px;
  border-radius: 10px;
}

#intro-text {
  width: 300px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: #f4f4f4;

}

#intro-head {
  width: 150px;
  height: auto;
  margin-top: -80px;
  margin-bottom: 20px;
}

#intro-text h5 {
  margin: 20px 0 20px 0;
  color: #333;
}

.intro-text-content {
  font-size: 14px;
  line-height: 1.6;
  color: #666;
}

.intro-text-content p {
  margin-bottom: 16px;
}

.intro-nav {
  flex: 1;
  padding: 40px;
  display: flex;
  flex-direction: column;
}

#intro-nav-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.intro-nav-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.intro-nav-row:last-child {
  margin-bottom: 0;
}

.intro-nav-thumb {
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  transition: transform 0.2s ease;
  display: inline-block;
}

.intro-nav-thumb:hover {
  transform: scale(1.05);
}

.intro-nav-thumb img {
  display: block;
  max-width: 150px;
  max-height: 150px;
  object-fit: contain;
}

/* Mobile styles for intro */
@media (max-width: 768px) {
  #intro-inner {
    width: 95%;
    flex-direction: column;
    min-height: auto;
  }
  
  #intro-text {
    width: 100%;
    padding: 30px;
  }
  
  .intro-nav {
    padding: 0 30px 30px;
  }
  
  .intro-nav-thumb img {
    max-width: 120px;
    max-height: 120px;
  }
  
  .intro-nav-row {
    gap: 15px;
  }
}