.mps-media-pet-gallery {
    margin-top: 24px;
}

.mps-media-pet-gallery-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.mps-media-pet-gallery-heading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mps-media-pet-gallery-title {
    margin: 0;
    font-size: 20px;
    line-height: 1.3;
    font-weight: 600;
}

.mps-media-pet-gallery-count {
    font-size: 13px;
    opacity: .65;
}

.mps-media-pet-gallery-header-actions,
.mps-media-gallery-selection-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mps-media-gallery-btn {
    border: 1px solid #9C27B0;
    background: #fff;
    color: #9C27B0;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
}

.mps-media-gallery-btn:hover {
    background: #9C27B0;
    color: #fff;
}

.mps-media-gallery-btn:disabled {
    opacity: .45;
    cursor: default;
}

.mps-media-gallery-btn-danger {
    color: #b42318;
}

.mps-media-pet-gallery-selection-bar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
}

.mps-media-pet-gallery-selection-bar[hidden] {
    display: none;
}

.mps-media-pet-gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.mps-media-pet-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    background: #f5f5f5;
    cursor: pointer;
}

.mps-media-pet-gallery-media {
    aspect-ratio: 1 / 1;
}

.mps-media-pet-gallery-image,
.mps-media-pet-gallery-video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.mps-media-gallery-selector {
    position: absolute;
    z-index: 3;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: rgba(0, 0, 0, .35);
    cursor: pointer;
}

.mps-media-gallery-selector[hidden] {
    display: none;
}

.mps-media-gallery-selector-mark {
    visibility: hidden;
    color: #fff;
    font-weight: 700;
}

.mps-media-pet-gallery-item[data-mps-selected="1"] {
    outline: 3px solid currentColor;
    outline-offset: -3px;
}

.mps-media-pet-gallery-item[data-mps-selected="1"]
.mps-media-gallery-selector {
    background: #222;
}

.mps-media-pet-gallery-item[data-mps-selected="1"]
.mps-media-gallery-selector-mark {
    visibility: visible;
}

.mps-media-pet-gallery-empty {
    padding: 24px 16px;
    text-align: center;
    border: 1px dashed #d7d7d7;
    border-radius: 10px;
}


/* Viewer */

.mps-media-viewer[hidden] {
    display: none !important;
}

.mps-media-viewer {
    position: fixed;
    inset: 0;
    z-index: 99999;
}

.mps-media-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .88);
}

.mps-media-viewer-dialog {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mps-media-viewer-stage {
    width: min(92vw, 1200px);
    height: min(88vh, 900px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mps-media-viewer-image,
.mps-media-viewer-video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.mps-media-viewer-close,
.mps-media-viewer-prev,
.mps-media-viewer-next {
    position: absolute;
    z-index: 3;
    border: 0;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    cursor: pointer;
}

.mps-media-viewer-close {
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 32px;
    line-height: 1;
}

.mps-media-viewer-prev,
.mps-media-viewer-next {
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 60px;
    border-radius: 8px;
    font-size: 40px;
}

.mps-media-viewer-prev {
    left: 12px;
}

.mps-media-viewer-next {
    right: 12px;
}

.mps-media-viewer-actions {
    position: absolute;
    z-index: 4;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.mps-media-viewer-actions[hidden] {
    display: none !important;
}

.mps-media-viewer-action {
    border: 0;
    border-radius: 8px;
    padding: 9px 14px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    cursor: pointer;
}

.mps-media-viewer-action:disabled {
    opacity: .5;
    cursor: default;
}

.mps-media-viewer-action-danger {
    color: #ffd7d7;
}

body.mps-media-viewer-open {
    overflow: hidden;
}


/* Desktop */

@media (min-width: 700px) {

    .mps-media-pet-gallery-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .mps-media-pet-gallery-selection-bar {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .mps-media-pet-gallery-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}


/* Mobile */

@media (max-width: 699px) {

    .mps-media-viewer-stage {
        width: 100vw;
        height: 100vh;
        padding: 56px 8px 72px;
        box-sizing: border-box;
    }

    .mps-media-viewer-prev,
    .mps-media-viewer-next {
        width: 38px;
        height: 52px;
    }

    .mps-media-viewer-actions {
        bottom: 12px;
        width: calc(100% - 24px);
    }
}

/* =========================================================
 * CROP EDITOR
 * ========================================================= */

.mps-media-crop-editor[hidden] {
    display: none !important;
}

.mps-media-crop-editor {
    position: fixed;
    inset: 0;
    z-index: 100000;

    display: flex;
    flex-direction: column;

    background: #111;
}

.mps-media-crop-editor-header {
    flex: 0 0 auto;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    padding: 12px 16px;

    background: rgba(0, 0, 0, .9);
    color: #fff;
}

.mps-media-crop-editor-title {
    font-weight: 600;
}

.mps-media-crop-editor-cancel,
.mps-media-crop-editor-apply {
    border: 0;
    border-radius: 8px;
    padding: 9px 14px;

    background: rgba(255, 255, 255, .14);
    color: #fff;

    cursor: pointer;
}

.mps-media-crop-editor-apply {
    background: #fff;
    color: #111;
}

.mps-media-crop-editor-stage {
    flex: 1 1 auto;
    min-height: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 12px;
}

.mps-media-crop-editor-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

/* =========================================================
   MEDIA UPLOADER — SCELTA SORGENTE
   ========================================================= */

.mps-media-uploader {
  position: relative;
  display: inline-block;
}

.mps-media-uploader-sources {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;

  min-width: 220px;

  padding: 8px;

  background: #9C27B0; /* viola medio */
  border-radius: 14px;

  box-shadow: 0 12px 28px rgba(0,0,0,.18);

  z-index: 1000;
}

.mps-media-uploader-sources[hidden] {
  display: none !important;
}

.mps-media-uploader-source {
  width: 100%;

  display: flex;
  align-items: center;
  justify-content: flex-start;

  margin: 0;
  padding: 10px 12px;

  border: 0;
  border-radius: 10px;

  background: transparent;

  color: #FFFFFF; /* bianco */
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;

  text-align: left;

  cursor: pointer;

  transition: background-color .15s ease;
}

.mps-media-uploader-source + .mps-media-uploader-source {
  margin-top: 4px;
}

.mps-media-uploader-source:hover,
.mps-media-uploader-source:focus {
  background: #A259FF; /* viola chiaro */
}

.mps-media-uploader-source:disabled {
  opacity: .55;
  cursor: default;
}

.mps-media-source-icon {
  width: 28px;
  flex: 0 0 28px;

  font-size: 20px;
  line-height: 1;

  text-align: center;
}