:host {
  display: block;
}

.gallery-block {
  display: grid;
  gap: 8px;
}

.gallery-toolbar {
  display: flex;
  justify-content: flex-end;
}

.lightbox {
  border: none;
  padding: 0;
  background: rgba(255, 255, 255, 0.95);
  max-width: 100vw;
  max-height: 100dvh;
  width: 100vw;
  height: 100dvh;
}

.lightbox::backdrop {
  background: rgba(255, 255, 255, 0.5);
}

.lightbox-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 24px;
  box-sizing: border-box;
  position: relative;
}

.lightbox img {
  max-width: calc(96vw - 48px);
  max-height: 92vh;
  object-fit: contain;
  display: block;
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  border: 0;
  border-radius: 999px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.18);
  color: #000;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.lightbox-close {
  top: 16px;
  right: 16px;
}

.lightbox-nav.is-prev {
  left: 16px;
}

.lightbox-nav.is-next {
  right: 16px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(var(--gallery-columns, 3), minmax(0, 1fr));
  gap: var(--gallery-gap, 8px);
  align-items: stretch;
}

.gallery-thumb {
  display: block;
  width: 100%;
  position: relative;
  padding: 0;
  border: 0;
  overflow: hidden;
  aspect-ratio: var(--gallery-ratio, 1 / 1);
  background: var(--owb-section-child-background-color, #f3f4f6);
  cursor: pointer;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px dashed var(--editor-border-color, #d1d5db);
  border-radius: 6px;
  padding: 14px;
  color: var(--owb-section-child-text-color, #6b7280);
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

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

.gallery-lightbox-image {
  display: block;
  max-width: min(92vw, 3600px);
  max-height: 90vh;
  object-fit: contain;
}

.gallery-lightbox-close,
.gallery-lightbox-nav {
  position: absolute;
  border: 0;
  border-radius: 999px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #000;
  cursor: pointer;
}

.gallery-lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
}

.gallery-lightbox-close {
  top: 16px;
  right: 16px;
}

.gallery-lightbox-nav.is-prev {
  left: 16px;
}

.gallery-lightbox-nav.is-next {
  right: 16px;
}

.gallery-textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  line-height: 1.4;
  font-family: inherit;
  background: var(--owb-section-child-background-color, #fff);
  color: var(--owb-section-child-text-color, inherit);
}
