:root {
  --gallery-panel: rgba(13, 23, 42, 0.92);
  --gallery-panel-border: rgba(133, 158, 214, 0.14);
  --gallery-text: #edf2fb;
  --gallery-muted: #9aa8c7;
  --gallery-shadow: 0 22px 60px rgba(0, 0, 0, 0.36);
  --gallery-scrollbar-track: rgba(255,255,255,0.05);
  --gallery-scrollbar-thumb: rgba(7, 14, 28, 0.62);
  --gallery-scrollbar-thumb-hover: rgba(12, 23, 45, 0.82);
  --gallery-stage-height: clamp(260px, 42vw, 520px);
}

html[data-theme="light"] {
  --gallery-panel: rgba(255, 255, 255, 0.86);
  --gallery-panel-border: rgba(13, 22, 38, 0.10);
  --gallery-text: #0d1626;
  --gallery-muted: #50607a;
  --gallery-shadow: 0 18px 42px rgba(16, 24, 40, 0.14);
  --gallery-scrollbar-track: rgba(13, 22, 38, 0.06);
  --gallery-scrollbar-thumb: rgba(13, 22, 38, 0.24);
  --gallery-scrollbar-thumb-hover: rgba(13, 22, 38, 0.34);
}

* { box-sizing: border-box; }

img { max-width: 100%; display: block; }
button { font: inherit; }

.site-header {
  top: 5px;
}

.page-shell {
  width: min(1440px, calc(100% - 28px));
  margin: 0 auto;
  padding: clamp(14px, 2vw, 32px) 0 clamp(20px, 3vw, 44px);
}

.page-header {
  display: flex;
  justify-content: center;
  gap: 28px;
  align-items: center;
  text-align: center;
  margin-top: 25px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 16px;
  color: #ffffff;
  letter-spacing: 0.18em;
  font-size: 0.92rem;
  font-weight: 500;
  text-transform: uppercase;
  text-shadow: none;
}

.eyebrow-brand {
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4.5vw, 4.2rem);
  line-height: 1.08;
  font-weight: 400;
  letter-spacing: 1px;
  color: var(--button-primary);
}

html[data-theme="light"] .eyebrow {
  color: var(--button-primary);
}

.intro {
  max-width: 480px;
  margin: 0;
  color: var(--gallery-muted);
  line-height: 1.6;
  font-size: clamp(14px, 1.3vw, 16px);
}

.gallery-layout {
  display: block;
}

.panel {
  background: var(--gallery-panel);
  border: 1px solid var(--gallery-panel-border);
  border-radius: 28px;
  box-shadow: var(--gallery-shadow);
  backdrop-filter: blur(20px);
}

.gallery-stage {
  padding: 18px;
  min-width: 0;
}

.stage-topbar {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 20px;
  margin-bottom: 14px;
}

.stage-copy {
  min-width: 0;
}

.stage-copy h2 {
  margin: 0 0 6px;
  font-size: clamp(20px, 2vw, 24px);
  line-height: 1.14;
}

.stage-copy p {
  margin: 0;
  color: var(--gallery-muted);
  font-size: clamp(13px, 1.15vw, 15px);
}

.stage-count {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  text-align: left;
  color: #d9e6ff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  pointer-events: none;
}

.stage-top-controls {
  min-width: min(360px, 100%);
  display: grid;
  gap: 8px;
}

.gallery-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  padding: 6px;
}

.gallery-search input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--gallery-text);
  font: inherit;
  outline: none;
  padding: 6px 8px;
}

.gallery-search input::placeholder {
  color: var(--gallery-muted);
}

#gallerySearchClear {
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
  color: var(--gallery-text);
  border-radius: 9px;
  padding: 6px 10px;
  cursor: pointer;
}

#gallerySearchClear:hover {
  background: rgba(255,255,255,0.1);
}

.gallery-search-meta {
  margin: 0;
  color: var(--gallery-muted);
  font-size: 0.84rem;
}

.stage-main {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 18px;
  align-items: stretch;
  height: var(--gallery-stage-height);
}

.stage-viewer {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.08);
  min-height: 0;
  height: var(--gallery-stage-height);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-figure {
  width: 100%;
  height: var(--gallery-stage-height);
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 1.6vw, 18px);
}

.stage-figure img {
  width: 100%;
  height: 100%;
  max-height: 350px;
  object-fit: contain;
  opacity: 1;
  transform: translateX(0);
  transition: opacity 0.28s ease, transform 0.28s ease;
  will-change: opacity, transform;
}

#mainSlideImage.is-first-slide {
  border-radius: 24px;
}

.slide-image-light { display: none; }
html[data-theme="light"] .slide-image-dark { display: none; }
html[data-theme="light"] .slide-image-light { display: block; }

.stage-figure img.is-changing-left {
  opacity: 0;
  transform: translateX(-18px);
}

.stage-figure img.is-changing-right {
  opacity: 0;
  transform: translateX(18px);
}

.stage-detail {
  min-height: 0;
  height: var(--gallery-stage-height);
  border-radius: 24px;
  background:
    radial-gradient(circle at top, rgba(108, 99, 255, 0.14), transparent 44%),
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
  border: 1px solid rgba(255,255,255,0.08);
  padding: clamp(18px, 2vw, 26px);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(7, 14, 28, 0.7);
  color: #f4f7ff;
  border-radius: 50%;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.nav-arrow:hover {
  background: rgba(18, 30, 56, 0.96);
  border-color: rgba(255,255,255,0.28);
}

.nav-arrow:active {
  transform: translateY(-50%) scale(0.97);
}

.nav-arrow.prev { left: 14px; }
.nav-arrow.next { right: 14px; }

.thumb-track-wrap {
  margin-top: 16px;
  overflow: hidden;
}

.thumb-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(148px, 16vw, 182px);
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: 2px 2px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--gallery-scrollbar-thumb) var(--gallery-scrollbar-track);
}

.thumb-track::-webkit-scrollbar {
  height: 10px;
}

.thumb-track::-webkit-scrollbar-track {
  background: var(--gallery-scrollbar-track);
  border-radius: 999px;
}

.thumb-track::-webkit-scrollbar-thumb {
  background: var(--gallery-scrollbar-thumb);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.06);
}

.thumb-track::-webkit-scrollbar-thumb:hover {
  background: var(--gallery-scrollbar-thumb-hover);
}

.thumb {
  appearance: none;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.07);
  color: var(--gallery-text);
  text-align: left;
  border-radius: 18px;
  padding: 10px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  scroll-snap-align: center;
}

.thumb:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.14);
}

.thumb.active {
  border-color: rgba(6, 134, 249, 0.72);
  box-shadow: 0 0 0 2px rgba(6, 134, 249, 0.16) inset;
  background: rgba(6, 134, 249, 0.08);
}

.thumb-image {
  width: 100%;
  aspect-ratio: 1.25 / 1;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.06));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
}

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

.thumb-title {
  margin: 10px 0 4px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.25;
}

.thumb-sub {
  margin: 0;
  color: var(--gallery-muted);
  font-size: 12px;
  line-height: 1.35;
}

.detail-label {
  margin: 0 0 10px;
  color: #96a7d2;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
}

.stage-detail h3 {
  margin: 0;
  font-size: clamp(26px, 2.5vw, 38px);
  line-height: 1.06;
}

.detail-subtitle {
  margin: 12px 0 16px;
  color: var(--button-primary);
  font-size: clamp(16px, 1.3vw, 18px);
}

.detail-description {
  margin: 0;
  padding-left: 18px;
  color: var(--gallery-muted);
  line-height: 1.6;
  font-size: clamp(14px, 1.05vw, 15px);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--gallery-scrollbar-thumb) var(--gallery-scrollbar-track);
}

.detail-description::-webkit-scrollbar {
  width: 10px;
}

.detail-description::-webkit-scrollbar-track {
  background: var(--gallery-scrollbar-track);
  border-radius: 999px;
}

.detail-description::-webkit-scrollbar-thumb {
  background: var(--gallery-scrollbar-thumb);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.06);
}

.detail-description::-webkit-scrollbar-thumb:hover {
  background: var(--gallery-scrollbar-thumb-hover);
}

.detail-description li {
  margin: 0 0 10px;
}

.detail-description li:last-child {
  margin-bottom: 0;
}

.detail-description strong {
  color: var(--gallery-text);
  font-weight: 700;
}

html[data-theme="light"] .stage-count {
  color: #d9e6ff;
}

html[data-theme="light"] .stage-viewer {
  background: linear-gradient(180deg, rgba(13, 22, 38, 0.02), rgba(13, 22, 38, 0.03));
  border-color: rgba(13, 22, 38, 0.10);
}

html[data-theme="light"] .stage-detail {
  background:
    radial-gradient(circle at top, rgba(105, 86, 255, 0.08), transparent 44%),
    linear-gradient(180deg, rgba(13, 22, 38, 0.02), rgba(13, 22, 38, 0.01));
  border-color: rgba(13, 22, 38, 0.10);
}

html[data-theme="light"] .thumb {
  background: rgba(13, 22, 38, 0.02);
  border-color: rgba(13, 22, 38, 0.10);
}

html[data-theme="light"] .thumb:hover {
  border-color: rgba(13, 22, 38, 0.18);
}

html[data-theme="light"] .thumb.active {
  border-color: rgba(6, 134, 249, 0.72);
  box-shadow: 0 0 0 2px rgba(6, 134, 249, 0.16) inset;
  background: rgba(6, 134, 249, 0.08);
}

html[data-theme="light"] .gallery-search {
  border-color: rgba(13, 22, 38, 0.14);
  background: rgba(13, 22, 38, 0.03);
}

html[data-theme="light"] #gallerySearchClear {
  border-color: rgba(13, 22, 38, 0.14);
  background: rgba(13, 22, 38, 0.06);
}

html[data-theme="light"] .thumb-image {
  background: linear-gradient(180deg, rgba(13, 22, 38, 0.02), rgba(13, 22, 38, 0.06));
}

html[data-theme="light"] .detail-label {
  color: #2b7de9;
}

html[data-theme="light"] .detail-subtitle {
  color: var(--button-primary);
}

@media (max-width: 1024px) {
  :root {
    --gallery-stage-height: clamp(240px, 40vw, 440px);
  }

  .stage-main {
    grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr);
  }
}

@media (max-width: 860px) {
  .gallery-stage {
    display: flex;
    flex-direction: column;
  }

  .stage-main {
    display: contents;
  }

  .stage-viewer {
    order: 2;
  }

  .thumb-track-wrap {
    order: 3;
  }

  .stage-detail {
    order: 4;
  }

  .page-header {
    display: block;
  }

  .intro {
    margin-top: 12px;
    max-width: 100%;
  }

  .stage-topbar {
    flex-direction: column;
    gap: 8px;
  }

  .stage-top-controls {
    width: 100%;
    min-width: 0;
  }

  .stage-count {
    top: 0;
    left: 0;
    text-align: left;
  }

  .stage-detail {
    min-height: clamp(220px, 52vw, 360px);
    height: clamp(220px, 52vw, 360px);
  }

  .thumb-track {
    grid-auto-columns: clamp(138px, 36vw, 170px);
  }
}

@media (max-width: 640px) {
  :root {
    --gallery-stage-height: clamp(220px, 62vw, 320px);
  }

  .page-shell {
    width: min(100% - 16px, 1440px);
    padding-top: 12px;
  }

  .gallery-stage {
    padding: 14px;
  }

  .stage-figure img {
    max-height: min(36vh, 300px);
  }

  .stage-detail {
    padding: 16px;
    min-height: clamp(200px, 56vw, 300px);
    height: clamp(200px, 56vw, 300px);
  }

  .thumb-track {
    grid-auto-columns: clamp(130px, 44vw, 158px);
    gap: 10px;
  }

  .nav-arrow {
    width: 42px;
    height: 42px;
  }

  .nav-arrow.prev { left: 10px; }
  .nav-arrow.next { right: 10px; }
}
