.emalm-media-edit-modal {
  --emalm-upload-surface: var(--emalm-ui-surface-1);
  --emalm-upload-surface-alt: var(--emalm-ui-surface-2);
  --emalm-upload-border: var(--emalm-ui-border);
  --emalm-upload-border-strong: var(--emalm-ui-border-strong);
  --emalm-upload-text: var(--emalm-ui-surface-text);
  --emalm-upload-muted: var(--emalm-ui-readable-muted);
  --emalm-upload-accent: var(--emalm-ui-primary-bg);
  --emalm-upload-accent-strong: var(--emalm-ui-primary-hover-bg);
  --emalm-upload-accent-text: var(--emalm-ui-primary-text);
  --emalm-upload-focus: var(--emalm-ui-focus);
}

.emalm-media-edit-modal .modal-dialog {
  margin: 40px auto;
  width: min(1100px, calc(100vw - 32px));
}

.emalm-media-edit-modal .modal-content {
  background: var(--emalm-ui-surface-1);
  border: 1px solid var(--emalm-ui-border);
  border-radius: 16px;
  color: var(--emalm-ui-surface-text);
  overflow: hidden;
}

.emalm-media-edit-header {
  background: linear-gradient(180deg, var(--emalm-ui-surface-1) 0%, var(--emalm-ui-surface-2) 100%);
  border-bottom: 1px solid var(--emalm-ui-border);
  padding: 22px 24px 18px;
}

.emalm-media-edit-header .close {
  /* Keep this dedicated control clear of the global generic button paint. */
  background: transparent !important;
  border-color: transparent !important;
  color: var(--emalm-ui-surface-text) !important;
  font-size: 30px;
  line-height: 1;
  opacity: 1;
  text-shadow: none;
}

.emalm-media-edit-header .close:hover,
.emalm-media-edit-header .close:focus {
  background: var(--emalm-ui-control-hover-bg) !important;
}

.emalm-media-edit-header .modal-title {
  color: var(--emalm-ui-surface-text);
  font-size: 34px;
  font-weight: 700;
  margin: 0;
}

.emalm-media-edit-subtitle {
  color: var(--emalm-ui-readable-muted);
  margin: 8px 0 0;
}

.emalm-media-edit-alert {
  background: var(--emalm-ui-danger-surface);
  border-color: var(--emalm-ui-danger-border);
  color: var(--emalm-ui-danger-readable-text);
  margin-bottom: 18px;
}

.emalm-media-edit-surface {
  background: transparent;
  box-shadow: none;
  margin: 0;
  padding: 0;
}

.emalm-media-edit-surface .emalm-upload-section {
  margin-left: 0;
  margin-right: 0;
}

.emalm-media-edit-preview {
  align-items: center;
  background: var(--emalm-ui-surface-2);
  border: 1px solid var(--emalm-ui-border);
  border-radius: 12px;
  display: flex;
  gap: 16px;
  margin-bottom: 18px;
  overflow: hidden;
  padding: 14px;
}

.emalm-media-edit-preview img {
  background: #161616;
  border-radius: 10px;
  display: block;
  height: 92px;
  object-fit: cover;
  width: 148px;
}

.emalm-media-edit-preview-copy {
  display: grid;
  gap: 4px;
}

.emalm-media-edit-preview-copy span {
  color: var(--emalm-ui-readable-muted);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.emalm-media-edit-assets {
  display: grid;
  gap: 14px;
}

.emalm-media-edit-asset-row {
  align-items: center;
  background: var(--emalm-ui-surface-2);
  border: 1px solid var(--emalm-ui-border);
  border-radius: 12px;
  display: grid;
  gap: 14px;
  grid-template-columns: 128px minmax(0, 1fr) auto;
  padding: 14px;
}

.emalm-media-edit-asset-row.is-removed {
  background: var(--emalm-ui-danger-surface);
  border-color: var(--emalm-ui-danger-border);
  color: var(--emalm-ui-danger-readable-text);
}

.emalm-media-edit-asset-row.is-removed .emalm-media-edit-asset-copy span {
  color: var(--emalm-ui-danger-readable-text);
}

.emalm-media-edit-asset-thumb img {
  background: #161616;
  border-radius: 10px;
  display: block;
  height: 92px;
  object-fit: cover;
  width: 100%;
}

.emalm-media-edit-asset-copy {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.emalm-media-edit-asset-copy span {
  color: var(--emalm-ui-readable-muted);
  font-size: 13px;
}

.emalm-media-edit-asset-actions {
  display: grid;
  gap: 8px;
}

.emalm-media-edit-file-input {
  max-width: 100%;
}

.emalm-media-edit-modal input::placeholder,
.emalm-media-edit-modal textarea::placeholder {
  color: var(--emalm-ui-readable-muted);
}

.emalm-media-edit-footer {
  background: var(--emalm-ui-surface-2);
  border-top: 1px solid var(--emalm-ui-border);
  padding: 16px 24px 22px;
}

.emalm-media-edit-modal .admin-button {
  background: var(--emalm-ui-surface-1) !important;
  border: 1px solid var(--emalm-ui-border-strong) !important;
  border-radius: 8px;
  color: var(--emalm-ui-surface-text) !important;
  font-weight: 600;
  padding: 8px 12px;
}

.emalm-media-edit-modal .admin-button:hover,
.emalm-media-edit-modal .admin-button:focus {
  background: var(--emalm-ui-control-hover-bg) !important;
  border-color: var(--emalm-ui-accent) !important;
}

.emalm-media-edit-modal .admin-button[disabled],
.emalm-media-edit-modal .emalm-upload-submit[disabled] {
  background: var(--emalm-ui-surface-2) !important;
  border-color: var(--emalm-ui-border) !important;
  color: var(--emalm-ui-readable-muted) !important;
  opacity: 1;
}

@media (max-width: 860px) {
  .emalm-media-edit-asset-row {
    grid-template-columns: 1fr;
  }

  .emalm-media-edit-asset-thumb img {
    height: 180px;
  }

  .emalm-media-edit-asset-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
