* { box-sizing: border-box; }
:root {
  --bg: #f3f3f3;
  --panel: #ffffff;
  --panel-soft: #fafafa;
  --text: #202124;
  --muted: #70757a;
  --line: #e5e7eb;
  --active: #1fb45d;
  --active-soft: rgba(31, 180, 93, 0.12);
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --shadow-mobile: 0 8px 18px rgba(15, 23, 42, 0.06);
  --radius-xl: 24px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

html, body { height: 100%; }
body {
  margin: 0;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #f6f6f6 0%, #ededed 100%);
  color: var(--text);
}
button { font: inherit; }
img { display: block; max-width: 100%; }

.page {
  width: min(100%, 1320px);
  margin: 28px auto;
  padding: 24px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}

.page,
.layout,
.gallery-shell,
.palette-shell,
.stage,
.thumb-section,
.thumb-swiper,
.swatch-swiper-wrap,
.swatch-swiper,
#swatches {
  min-width: 0;
}

.gallery-shell,
.palette-shell {
  background: var(--panel);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.gallery-shell {
  padding: 24px;
  min-width: 0;
}

.palette-shell {
  padding: 20px;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
}

.gallery-head,
.palette-head,
.section-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.gallery-head { margin-bottom: 18px; }
.gallery-copy { min-width: 0; }

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.gallery-head h1,
.palette-head h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.gallery-head p,
.palette-head p,
.thumb-label,
.thumb-tip {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.summary-pill {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 999px;
  background: #f5f7f8;
  border: 1px solid var(--line);
  font-size: 13px;
  color: #4b5563;
  white-space: nowrap;
}

.stage {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: #dde2e6;
  aspect-ratio: 4 / 2.7;
}

.main-swiper,
.thumb-swiper {
  width: 100%;
}

.main-swiper,
.main-swiper .swiper-wrapper,
.main-swiper .swiper-slide {
  height: 100%;
}

.main-swiper .swiper-slide { overflow: hidden; }
.main-swiper .swiper-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: rgba(17, 24, 39, 0.22);
  backdrop-filter: blur(6px);
  transition: background .2s ease, transform .2s ease, opacity .2s ease;
}

.nav-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 11px;
  height: 11px;
  border-top: 2px solid #fff;
  border-right: 2px solid #fff;
}

.nav-btn:hover { background: rgba(17, 24, 39, 0.36); }
.nav-btn:active { transform: translateY(-50%) scale(0.96); }
.nav-btn.prev { left: 16px; }
.nav-btn.prev::before { transform: rotate(-135deg); left: 3px; }
.nav-btn.next { right: 16px; }
.nav-btn.next::before { transform: rotate(45deg); right: 3px; }

.thumb-section { margin-top: 16px; }
.section-bar { margin-bottom: 10px; align-items: center; }
.thumb-label,
.thumb-tip { margin: 0; font-size: 13px; }
.thumb-tip { white-space: nowrap; }
.thumb-swiper { overflow: hidden; }

.thumb-swiper .swiper-slide {
  width: 96px;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  opacity: 0.58;
  border: 2px solid transparent;
  transition: opacity .2s ease, border-color .2s ease, transform .2s ease;
}

.thumb-swiper .swiper-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-swiper .swiper-slide-thumb-active {
  opacity: 1;
  border-color: var(--active);
  transform: translateY(-1px);
}

.palette-head { margin-bottom: 16px; }

.swatch-swiper-wrap { width: 100%; }
.swatch-swiper { width: 100%; overflow: visible; }
.swatch-swiper .swiper-wrapper {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.swatch-swiper .swiper-slide {
  width: auto;
  height: auto;
}

.swatch {
  position: relative;
  width: 100%;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 18px;
  overflow: hidden;
  background: #e5e7eb;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.swatch:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
}

.swatch.active {
  border-color: var(--active);
  box-shadow: 0 0 0 4px var(--active-soft);
}

.swatch__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.swatch__veil {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0);
  transition: background .2s ease;
}

.swatch__tone {
  width: 42%;
  height: 42%;
  min-width: 46px;
  min-height: 46px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: scale(.72);
  transition: opacity .2s ease, transform .2s ease;
}

.swatch__check {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.6);
  opacity: 0;
  transform: scale(.7);
  transition: opacity .2s ease, transform .2s ease;
}

.swatch__check::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 6px;
  height: 11px;
  margin: auto;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg) translate(-1px, -1px);
}

.swatch.active .swatch__check {
  opacity: 1;
  transform: scale(1);
}

@media (hover: hover) and (pointer: fine) {
  .swatch:hover .swatch__veil,
  .swatch:focus-visible .swatch__veil {
    background: rgba(17, 24, 39, 0.2);
  }

  .swatch:hover .swatch__tone,
  .swatch:focus-visible .swatch__tone {
    opacity: 1;
    transform: scale(1);
  }
}

.swatch:focus-visible {
  outline: 0;
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .page {
    width: 100%;
    margin: 0;
    padding: 12px;
  }

  .layout { gap: 14px; }

  .gallery-shell,
  .palette-shell {
    border-radius: 18px;
    box-shadow: var(--shadow-mobile);
    padding: 16px;
  }

  .gallery-head,
  .palette-head,
  .section-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .gallery-head h1,
  .palette-head h2 { font-size: 24px; }
  .gallery-head p,
  .palette-head p { font-size: 13px; }
  .summary-pill { padding: 8px 12px; }

  .stage {
    aspect-ratio: 1 / 0.9;
    border-radius: 16px;
  }

  .main-swiper .swiper-slide img {
    object-fit: contain;
    background: #e7ebef;
  }

  .thumb-swiper .swiper-slide {
    width: clamp(72px, 22vw, 92px);
    border-radius: 10px;
  }

  .palette-shell { padding-top: 14px; }

  .swatch-swiper {
    overflow: hidden;
    margin: 0 -2px;
    padding: 2px 2px 8px;
  }

  .swatch-swiper .swiper-wrapper {
    display: flex;
    gap: 0;
  }

  .swatch-swiper .swiper-slide {
    width: 84px !important;
    flex: 0 0 84px;
    height: auto;
  }

  .swatch {
    width: 84px;
    border-radius: 16px;
  }

  .swatch:hover {
    transform: none;
    box-shadow: none;
  }

  .swatch__veil,
  .swatch__tone { display: none; }

  .swatch.active {
    box-shadow: 0 0 0 3px var(--active-soft);
  }

  .swatch.active::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 8px;
    height: 4px;
    border-radius: 999px;
    background: var(--active);
  }
}

@media (max-width: 560px) {
  body { background: #f5f5f5; }
  .page { padding: 10px; }

  .gallery-shell,
  .palette-shell {
    border-radius: 16px;
    padding: 14px;
  }

  .gallery-head h1,
  .palette-head h2 { font-size: 22px; }
  .stage { aspect-ratio: 1 / 1.02; }

  .nav-btn {
    width: 38px;
    height: 38px;
  }

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

  .thumb-swiper .swiper-slide { width: 68px; }

  .swatch-swiper .swiper-slide {
    width: 78px !important;
    flex: 0 0 78px;
  }

  .swatch {
    width: 78px;
    border-radius: 14px;
  }

  .swatch__check {
    width: 22px;
    height: 22px;
    right: 8px;
    bottom: 8px;
  }
}
