body {
  margin: 0;
  padding: 0 0 48px 0;
  background: #f6f6f6;
  color: #222;
  font-family: 'Montserrat', sans-serif;
  box-sizing: border-box;
  overflow-x: hidden;
}
.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 80px;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  z-index: 100;
  padding: 0 2rem;
  box-sizing: border-box;
  border-bottom: 1.5px solid #f0f0f0;
}
.portfolio-title {
  font-size: 2.2rem;
  font-weight: 700;
  color: #222;
  margin-right: auto;
  letter-spacing: 0.04em;
  display: flex;
  align-items: baseline;
  gap: 0.3em;
}
.portfolio-sub {
  font-size: 1.05rem;
  font-weight: 400;
  color: #444;
  margin-left: 0.15em;
  letter-spacing: 0.01em;
}
.navbar {
  margin-left: auto;
  display: flex;
  gap: 2.2rem;
}
.navbar a {
  color: #444;
  text-decoration: none;
  font-size: 1.18rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}
.navbar a.active,
.navbar a:hover {
  color: #1565c0;
  background: rgba(0, 0, 0, 0.04);
}
.gallery-section {
  width: 100%;
  max-width: 1200px;
  margin: 120px auto 0 auto;
  padding: 64px 0 48px 0;
  background: #fff;
  border-radius: 32px;
  box-shadow: 0 8px 32px rgba(80, 120, 180, 0.07);
  border: 1px solid #222;
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
  overflow-x: hidden;
  margin-bottom: 80px;
}
.gallery-main,
.gallery-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 0;
  justify-content: center;
  box-sizing: border-box;
  margin-bottom: 5.5rem;
}
.gallery-main-item,
.gallery-row-item {
  background: #fff;
  border-radius: 32px;
  box-shadow: 0 8px 32px rgba(80, 120, 180, 0.12);
  padding: 2.5rem 2rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  border: 1px solid transparent;
  min-width: 600px;
  max-width: 900px;
  width: 80%;
  min-height: 380px;
  margin: 0 auto 5.5rem auto;
  transition: box-shadow 0.18s, transform 0.18s, border 0.18s;
  position: relative;
  box-sizing: border-box;
  gap: 1.5rem;
}
.gallery-main-item:last-child,
.gallery-row-item:last-child {
  margin-bottom: 0;
}
.gallery-main-item:hover,
.gallery-main-item:focus-visible,
.gallery-row-item:hover,
.gallery-row-item:focus-visible {
  box-shadow: 0 0 0 1px #2986f7, 0 8px 32px rgba(21, 101, 192, 0.13);
  border: 1px solid #2986f7;
  transform: translateY(-8px) scale(1.03);
  z-index: 2;
}
.gallery-main-item img,
.gallery-row-item img {
  width: 100%;
  max-width: 420px;
  height: 220px;
  object-fit: contain;
  border-radius: 20px;
  background: #f6f6f6;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 16px rgba(80, 120, 180, 0.1);
  transition: box-shadow 0.18s, transform 0.18s;
  display: block;
}
.gallery-main-caption,
.gallery-row-caption {
  font-size: 1.3rem;
  font-weight: 700;
  color: #222;
  text-align: center;
  margin-top: 0.2em;
  letter-spacing: 0.01em;
}
.gallery-row-caption {
  font-size: 1.13rem;
  font-weight: 600;
  margin-top: 0.1em;
}
.toggle-desc-btn {
  display: inline-block;
  margin-top: 0.7em;
  font-size: 1.08rem;
  color: #1565c0;
  background: #fafdff;
  border-radius: 10px;
  padding: 0.4em 1em;
  font-family: 'Montserrat', sans-serif;
  box-shadow: 0 1px 6px rgba(80, 120, 180, 0.06);
  border: none;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, transform 0.18s;
}
.toggle-desc-btn:hover {
  background: #e6f0ff;
  color: #2986f7;
  transform: scale(1.07);
}
.gallery-popup {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 96vw;
  max-width: 540px;
  min-width: 260px;
  background: rgba(246, 250, 255, 0.98);
  border-radius: 32px;
  box-shadow: 0 8px 32px rgba(80, 120, 180, 0.16);
  z-index: 2000;
  padding: 2rem 1.2rem 1.2rem 1.2rem;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  animation: fadeIn 0.25s;
  box-sizing: border-box;
  overflow-y: auto;
  min-height: 320px;
  max-height: 90vh;
}
.gallery-popup.active {
  display: flex;
}
.gallery-popup-close {
  position: absolute;
  top: 1.2rem;
  right: 1.7rem;
  font-size: 2rem;
  color: #1565c0;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 20;
}
.gallery-popup-inner {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.2em;
}
.gallery-popup-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5em;
  color: #222;
}
.gallery-popup-desc {
  font-size: 1.02rem;
  color: #222;
  margin-bottom: 0.7em;
}
.gallery-popup-images {
  display: flex;
  gap: 1.2em;
  margin-bottom: 0.7em;
}
.gallery-popup-images img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 10px;
  background: #f6f6f6;
  box-shadow: 0 1px 6px rgba(80, 120, 180, 0.09);
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.18s;
}
.gallery-popup-images img:hover {
  box-shadow: 0 0 0 2px #2986f7, 0 1px 6px rgba(80, 120, 180, 0.13);
  transform: scale(1.08);
}
.gallery-popup-texts {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  font-size: 0.98rem;
  color: #1565c0;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.image-popup {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
  z-index: 9999;
}
.image-popup.active {
  display: flex;
}
.popup-img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 16px;
  box-shadow: 0 0 20px #000;
}
.footer-bar {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 48px;
  background: rgba(255, 255, 255, 0.92);
  border-top: 1.5px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  box-sizing: border-box;
  padding-left: 2rem;
}
.footer-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #222;
  display: flex;
  align-items: baseline;
  gap: 0.3em;
}
.footer-sub {
  font-size: 1.05rem;
  font-weight: 400;
  color: #444;
  margin-left: 0.15em;
  letter-spacing: 0.01em;
}
.scroll-top-btn {
  position: fixed;
  right: 32px;
  bottom: 32px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s, box-shadow 0.2s;
}
.scroll-top-btn img {
  width: 32px;
  height: 32px;
  display: block;
  margin: auto;
  pointer-events: none;
}
.scroll-top-btn:hover {
  background: #e6f0ff;
  box-shadow: 0 6px 24px rgba(0, 123, 255, 0.18);
}
@media (max-width: 1200px) {
  .gallery-section {
    max-width: 98vw;
    padding: 16px 0 32px 0;
  }
  .gallery-main-item,
  .gallery-row-item {
    min-width: 60vw;
    max-width: 98vw;
    width: 92vw;
  }
  .gallery-popup {
    min-width: 60vw;
    max-width: 98vw;
    width: 98vw;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}
@media (max-width: 900px) {
  .gallery-section {
    padding: 1.2rem 0.5rem 2.5rem 0.5rem;
    max-width: 98vw;
    min-height: 0;
  }
  .gallery-main,
  .gallery-row {
    gap: 0;
  }
  .gallery-main-item,
  .gallery-row-item {
    min-width: 120px;
    max-width: 98vw;
    width: 96vw;
    padding: 1.2rem 0.7rem 1rem 0.7rem;
  }
  .gallery-main-item img,
  .gallery-row-item img {
    max-width: 90vw;
    height: 120px;
  }
  .gallery-popup {
    min-width: 0;
    max-width: 98vw;
    width: 98vw;
    padding: 1.2rem 0.7rem 1rem 0.7rem;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  .gallery-popup-images img {
    width: 44px;
    height: 44px;
  }
}
@media (max-width: 600px) {
  .header {
    height: 48px;
    padding: 0 0.4rem;
  }
  .portfolio-title {
    font-size: 0.9rem;
  }
  .navbar {
    gap: 0.5rem;
  }
  .navbar a {
    font-size: 0.8rem;
    padding: 0.2rem 0.3rem;
  }
  .gallery-section {
    padding: 0.7rem 0.2rem 1.2rem 0.2rem;
    border-radius: 7px;
  }
  .gallery-main-item,
  .gallery-row-item {
    min-width: 80px;
    width: 98vw;
    padding: 0.7rem 0.2rem 0.7rem 0.2rem;
  }
  .gallery-main-item img,
  .gallery-row-item img {
    max-width: 98vw;
    height: 70px;
  }
  .gallery-popup {
    padding: 0.7rem 0.2rem 0.7rem 0.2rem;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  .footer-bar {
    height: 38px;
    padding-left: 0.5rem;
  }
  .footer-title {
    font-size: 1rem;
  }
  .scroll-top-btn {
    right: 12px;
    bottom: 12px;
    width: 38px;
    height: 38px;
  }
  .scroll-top-btn img {
    width: 20px;
    height: 20px;
  }
}
