.lightbox[hidden] {
  display: none !important;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
}

.lightbox.is-open {
  display: block !important;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: var(--color-overlay);
}

.lightbox__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(920px, calc(100% - 2rem));
  max-height: calc(100vh - 4rem);
  margin: 2rem auto;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-md);
}

.lightbox__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.lightbox__count {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.lightbox__controls {
  display: flex;
  gap: 0.4rem;
}

.lightbox__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: #fff;
  color: var(--color-text);
  cursor: pointer;
}

.lightbox__icon-btn:hover {
  background: var(--color-bg-alt);
}

.lightbox__icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.lightbox__body {
  overflow: auto;
  padding: 1.5rem 1.6rem 1.75rem;
}

.lightbox-slide__media {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 220px;
  margin-bottom: 1.25rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
}

.lightbox-slide__media img {
  max-height: 180px;
  width: auto;
  object-fit: contain;
}

.lightbox-slide h2 {
  margin: 0 0 0.35rem;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.lightbox-slide__subtitle {
  margin: 0 0 1rem;
  color: var(--color-text-muted);
}

.lightbox-slide ul {
  margin: 0 0 1.25rem;
  padding-left: 1.15rem;
}

.lightbox-slide li + li {
  margin-top: 0.45rem;
}

.lightbox-slide__links,
.lightbox-slide__gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin: 0 0 1.15rem;
}

.lightbox-media {
  width: min(100%, 240px);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: #fff;
  color: inherit;
}

.lightbox-media:hover {
  color: inherit;
}

.lightbox-media img,
.lightbox-media video {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #f1f3f1;
}

.lightbox-media figcaption,
.lightbox-media .lightbox-media__caption {
  padding: 0.55rem 0.7rem 0.7rem;
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.lightbox-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  font-size: 0.88rem;
  font-weight: 600;
}

.lightbox-link:hover {
  background: var(--color-bg-alt);
  color: var(--color-text);
}

.lightbox__thumbs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-alt);
}

.lightbox__thumb {
  flex: 0 0 72px;
  width: 72px;
  height: 52px;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.lightbox__thumb.is-active {
  border-color: var(--color-accent);
}

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

@media (max-width: 640px) {
  .lightbox__dialog {
    width: calc(100% - 1rem);
    max-height: calc(100vh - 1.5rem);
    margin: 0.75rem auto;
  }

  .lightbox__body {
    padding: 1.15rem 1rem 1.25rem;
  }
}
