:root {
  --overlay-backdrop: rgba(11, 20, 16, .55);
  --overlay-shadow: 0 24px 70px rgba(8, 30, 22, .22);
  --overlay-drawer-shadow: -18px 0 55px rgba(17, 38, 30, .18);
  --overlay-line: #d8e1dd;
  --overlay-surface: #fff;
  --overlay-lightbox-surface: #101713;
}

dialog[data-overlay-variant] {
  box-sizing: border-box;
  max-height: calc(100dvh - 24px);
  overflow: hidden;
  border: 0;
  color: inherit;
  background: var(--overlay-surface);
  box-shadow: var(--overlay-shadow);
}

dialog[data-overlay-variant]::backdrop,
.overlay-discard-dialog::backdrop {
  background: var(--overlay-backdrop);
  backdrop-filter: none;
}

dialog[data-overlay-variant="modal"] {
  max-width: calc(100vw - 24px);
  border-radius: 10px;
}

dialog[data-overlay-variant="modal"] > form {
  min-height: 0;
  max-height: calc(100dvh - 24px);
  overflow: hidden;
}

dialog[data-overlay-variant="drawer"] {
  width: min(var(--overlay-drawer-width, 680px), calc(100vw - 40px));
  height: 100dvh;
  max-width: var(--overlay-drawer-width, 680px);
  max-height: 100dvh;
  margin: 0 0 0 auto;
  border-left: 1px solid var(--overlay-line);
  border-radius: 0;
  box-shadow: var(--overlay-drawer-shadow);
}

dialog[data-overlay-variant="drawer"] > :is(form, div) {
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

dialog[data-overlay-variant="lightbox"] {
  width: min(92vw, 920px);
  height: min(88dvh, 720px);
  max-width: 920px;
  max-height: 720px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .34);
}

.system-image-lightbox[open] {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: stretch;
}

.system-image-lightbox-stage {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  background: #f4f7f5;
}

.system-image-lightbox-stage > img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  object-fit: contain;
}

.system-image-lightbox > footer {
  min-height: 48px;
  padding: 13px 56px 13px 16px;
  border-top: 1px solid #d9e2dd;
  background: #fff;
}

.system-image-lightbox > footer p {
  margin: 0;
  overflow: hidden;
  color: #42584f;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Click-to-preview thumbnails rely on cursor/focus affordance, not corner icons. */
.product-image-zoom-hint { display: none !important; }

dialog[data-overlay-variant="lightbox"] > button {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  display: grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(28, 47, 38, .22);
  border-radius: 50%;
  color: #42584f;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 2px 8px rgba(15, 35, 27, .12);
  cursor: pointer;
}

dialog[data-overlay-variant="lightbox"] > button:focus-visible {
  outline: 3px solid rgba(23, 107, 80, .35);
  outline-offset: 3px;
}

.overlay-discard-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(8, 30, 22, .3);
}

.overlay-discard-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 14px;
  padding: 22px;
}

.overlay-discard-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  color: #9a4b19;
  background: #fff1e7;
}

.overlay-discard-copy h2 { margin: 0 0 6px; font-size: 18px; }
.overlay-discard-copy p { margin: 0; color: #65756e; font-size: 13px; line-height: 1.5; }
.overlay-discard-actions { display: flex; grid-column: 1 / -1; justify-content: flex-end; gap: 8px; padding-top: 6px; }

@media (max-width: 760px) {
  dialog[data-overlay-variant="modal"],
  dialog[data-overlay-variant="drawer"] {
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border: 0;
    border-radius: 0;
  }

  dialog[data-overlay-variant="modal"] > form { max-height: 100dvh; }

  /* Product Specification opens one server-rendered section at a time. The
     general mobile product wizard must not hide that active drawer section. */
  .product-context .product-section-editor [data-product-settings-section]:not([hidden]) {
    display: block;
  }

  dialog[data-overlay-variant="lightbox"] {
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0;
  }

  .system-image-lightbox-stage { padding: 16px; }
  .system-image-lightbox > footer { min-height: 52px; padding: 14px 58px 14px 14px; }

  .overlay-discard-card { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  dialog[data-overlay-variant] { animation: none !important; transition: none !important; }
}
