.amg {
  --amg-radius: 28px;
  --amg-aspect-ratio: 1 / 1;
  --amg-surface: #ffffff;
  --amg-border: rgba(148, 163, 184, 0.24);
  --amg-shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
  --amg-overlay: linear-gradient(180deg, rgba(15, 23, 42, 0.02), rgba(15, 23, 42, 0.38));
  position: relative;
  display: grid;
  gap: 12px;
}

.amg-shell {
  position: relative;
  border-radius: var(--amg-radius);
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 38%),
    linear-gradient(160deg, #eef4ff 0%, #ffffff 55%, #f4fbf4 100%);
  border: 1px solid var(--amg-border);
  box-shadow: var(--amg-shadow);
}

.amg-viewport {
  position: relative;
  aspect-ratio: var(--amg-aspect-ratio);
  overflow: hidden;
}

.amg-track {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  touch-action: pan-y pinch-zoom;
}

.amg-track::-webkit-scrollbar {
  display: none;
}

.amg-slide {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  user-select: none;
  background: #dbe7fb;
}

.amg-slide::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--amg-overlay);
  pointer-events: none;
}

.amg-media,
.amg-video-frame,
.amg-video {
  width: 100%;
  height: 100%;
}

.amg-media {
  object-fit: cover;
  background: linear-gradient(135deg, #dbeafe, #e2e8f0);
  cursor: zoom-in;
}

.amg-video-frame {
  position: relative;
  background: #020617;
}

.amg-video {
  display: block;
  object-fit: cover;
  background: #020617;
}

.amg-video-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.amg-video-poster.is-hidden,
.amg-video-play.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.amg-video-play,
.amg-video-mute,
.amg-nav,
.amg-count {
  position: absolute;
  z-index: 3;
}

.amg-video-play {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: none;
  border-radius: 999px;
  padding: 18px 24px;
  background: rgba(15, 23, 42, 0.78);
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.28);
}

.amg-video-mute {
  right: 16px;
  bottom: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.18);
}

.amg-nav {
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #0f172a;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
}

.amg-nav[disabled] {
  opacity: 0.35;
  cursor: default;
}

.amg-nav-prev {
  left: 16px;
}

.amg-nav-next {
  right: 16px;
}

.amg-count {
  right: 16px;
  top: 16px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.68);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.amg-dots {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 3;
}

.amg-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.48);
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}

.amg-dot.is-active {
  transform: scale(1.18);
  background: #ffffff;
}

.amg-thumbs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.amg-thumbs::-webkit-scrollbar {
  display: none;
}

.amg-thumb {
  position: relative;
  flex: 0 0 88px;
  width: 88px;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 18px;
  overflow: hidden;
  background: #e2e8f0;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.amg-thumb img,
.amg-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.amg-thumb.is-active {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.amg-thumb-badge {
  position: absolute;
  inset: auto auto 8px 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.76);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.amg-empty {
  display: grid;
  place-items: center;
  aspect-ratio: var(--amg-aspect-ratio);
  border-radius: var(--amg-radius);
  border: 1px dashed rgba(148, 163, 184, 0.42);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 32%),
    linear-gradient(160deg, #eff6ff 0%, #f8fafc 100%);
  color: #2563eb;
  font-size: clamp(56px, 8vw, 96px);
}

.amg-lightbox {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.96);
  z-index: 10050;
  overscroll-behavior: contain;
}

.amg-lightbox.is-open {
  display: flex;
}

.amg-lightbox-close,
.amg-lightbox-index {
  position: absolute;
  z-index: 2;
}

.amg-lightbox-close {
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 22px;
  cursor: pointer;
}

.amg-lightbox-index {
  left: max(16px, env(safe-area-inset-left));
  top: max(16px, env(safe-area-inset-top));
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
}

.amg-lightbox-stage {
  position: relative;
  width: min(100vw, 1100px);
  height: min(100vh, 860px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.amg-lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}

.amg-lightbox-hint {
  position: absolute;
  left: 50%;
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
  transform: translateX(-50%);
  color: rgba(248, 250, 252, 0.78);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 900px) {
  .amg {
    --amg-radius: 22px;
  }

  .amg-thumb {
    flex-basis: 74px;
    width: 74px;
    border-radius: 16px;
  }
}

@media (max-width: 640px) {
  .amg-video-play {
    padding: 16px 20px;
    font-size: 14px;
  }

  .amg-nav {
    display: none;
  }

  .amg-count {
    top: auto;
    bottom: 54px;
    right: 12px;
  }

  .amg-dots {
    bottom: 12px;
  }

  .amg-thumbs {
    gap: 8px;
  }

  .amg-lightbox-stage {
    width: 100vw;
    height: 100vh;
    padding: 16px;
  }
}
