.accordion-gallery {
  --ag-accent: #f2efe8;
  --ag-overlay: #0c0a12;
  --ag-text: #f7f4ee;
  --ag-gap: 10px;
  --ag-radius: 18px;
  --ag-media-size: 240px;

  display: flex;
  flex-direction: row;
  gap: var(--ag-gap);
  width: 100%;
  max-width: 100%;
  perspective: 1400px;
  perspective-origin: 50% 50%;
}

.accordion-gallery--vertical {
  flex-direction: column;
}

.ag-panel {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--ag-radius);
  cursor: pointer;
  display: block;
  text-decoration: none;
  outline: none;
  transform-style: preserve-3d;
  transform-origin: center center;
  background: #14101c;
  box-shadow:
    0 18px 40px -24px rgba(0, 0, 0, 0.85),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  will-change: flex-grow, transform;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 0.35s ease;
}

.ag-panel--active {
  box-shadow:
    0 22px 48px -22px rgba(0, 0, 0, 0.9),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.ag-panel:focus-visible {
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--ag-accent) 85%, transparent),
    0 22px 48px -22px rgba(0, 0, 0, 0.9);
}

.ag-panel__frame {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
}

.ag-panel__media {
  --ag-gray: 1;
  --ag-dim: 0.4;
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--ag-media-size);
  height: 100%;
  filter: grayscale(var(--ag-gray)) saturate(0.85);
  will-change: transform, filter;
}

.accordion-gallery--vertical .ag-panel__media {
  width: 100%;
  height: var(--ag-media-size);
}

.ag-panel__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.ag-panel__overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(
      180deg,
      transparent 38%,
      color-mix(in srgb, var(--ag-overlay) 55%, transparent) 72%,
      color-mix(in srgb, var(--ag-overlay) 88%, transparent) 100%
    ),
    color-mix(in srgb, var(--ag-overlay) calc(var(--ag-dim, 0.4) * 100%), transparent);
}

.ag-panel__label {
  position: absolute;
  left: 20px;
  bottom: 20px;
  right: 20px;
  display: flex;
  align-items: stretch;
  gap: 12px;
  pointer-events: none;
  z-index: 2;
  max-width: min(100%, 28rem);
}

.ag-panel__bar {
  flex: 0 0 auto;
  width: 2px;
  align-self: stretch;
  min-height: 2.6em;
  border-radius: 2px;
  background: var(--ag-accent);
  opacity: 0;
  box-shadow: 0 0 14px color-mix(in srgb, var(--ag-accent) 35%, transparent);
}

.ag-panel__copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.ag-panel__text {
  color: var(--ag-text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-weight: 600;
  font-size: clamp(1.05rem, 1.5vw, 1.35rem);
  letter-spacing: 0.08em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.55);
}

.ag-panel__caption {
  color: color-mix(in srgb, var(--ag-text) 72%, transparent);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-weight: 400;
  font-size: clamp(0.78rem, 1vw, 0.92rem);
  letter-spacing: 0.1em;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.45);
}

@media (max-width: 520px) {
  .accordion-gallery {
    flex-direction: column;
    perspective: none;
    height: auto !important;
  }
  .ag-panel {
    min-height: 96px;
    transform: none !important;
  }
  .accordion-gallery .ag-panel__media {
    width: 100%;
    height: var(--ag-media-size);
  }
  .ag-panel__label {
    left: 14px;
    bottom: 14px;
    right: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ag-panel,
  .ag-panel__media {
    will-change: auto;
  }
}
